Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55821 - sandbox/statistics/functional/boost/functional
From: erwann.rogard_at_[hidden]
Date: 2009-08-27 20:51:48


Author: e_r
Date: 2009-08-27 20:51:47 EDT (Thu, 27 Aug 2009)
New Revision: 55821
URL: http://svn.boost.org/trac/boost/changeset/55821

Log:
modif
Text files modified:
   sandbox/statistics/functional/boost/functional/zscore.hpp | 28 +++++++++++++++++-----------
   1 files changed, 17 insertions(+), 11 deletions(-)

Modified: sandbox/statistics/functional/boost/functional/zscore.hpp
==============================================================================
--- sandbox/statistics/functional/boost/functional/zscore.hpp (original)
+++ sandbox/statistics/functional/boost/functional/zscore.hpp 2009-08-27 20:51:47 EDT (Thu, 27 Aug 2009)
@@ -12,21 +12,27 @@
 #include <boost/accumulators/accumulators.hpp>
 #include <boost/accumulators/statistics/mean.hpp>
 #include <boost/accumulators/statistics/variance.hpp>
+#include <boost/functional/mean_var_accumulator.hpp>
 
 namespace boost{
 namespace functional{
 
-template<typename T>
-struct zscore{
- typedef T result_type;
- zscore(){}
- template<typename T1>
- result_type operator()(const A& a, const T1& x)const{
- T m = static_cast<T>(boost::accumulators::mean(a));
- T s = static_cast<T>(boost::accumulators::variance(a));
- s = std::sqrt(s);
- return (x - m)/s;
- }
+template<typename T,typename A = typename mean_var_accumulator<T>::type>
+class zscore{
+ public:
+ typedef T result_type;
+ zscore(){}
+ zscore(const A& a):a_(a){}
+ template<typename T1>
+ result_type operator()(const T1& x)const{
+ T m = boost::accumulators::mean(this->a());
+ T s = boost::accumulators::variance(this->a());
+ s = std::sqrt(s);
+ return (x - m)/s;
+ }
+ const A& a()const{ return this->a_; }
+ private:
+ A a_;
 };
 
 


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk