|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r59485 - sandbox/statistics/detail/accumulator/boost/statistics/detail/accumulator/statistics
From: erwann.rogard_at_[hidden]
Date: 2010-02-04 19:04:38
Author: e_r
Date: 2010-02-04 19:04:37 EST (Thu, 04 Feb 2010)
New Revision: 59485
URL: http://svn.boost.org/trac/boost/changeset/59485
Log:
a
Added:
sandbox/statistics/detail/accumulator/boost/statistics/detail/accumulator/statistics/zscore.hpp
- copied, changed from r56641, /sandbox/statistics/functional/boost/functional/zscore.hpp
Text files modified:
sandbox/statistics/detail/accumulator/boost/statistics/detail/accumulator/statistics/count_less_than.hpp | 5 -
sandbox/statistics/detail/accumulator/boost/statistics/detail/accumulator/statistics/zscore.hpp | 122 +++++++++++++++++++++++++++++++++------
2 files changed, 101 insertions(+), 26 deletions(-)
Modified: sandbox/statistics/detail/accumulator/boost/statistics/detail/accumulator/statistics/count_less_than.hpp
==============================================================================
--- sandbox/statistics/detail/accumulator/boost/statistics/detail/accumulator/statistics/count_less_than.hpp (original)
+++ sandbox/statistics/detail/accumulator/boost/statistics/detail/accumulator/statistics/count_less_than.hpp 2010-02-04 19:04:37 EST (Thu, 04 Feb 2010)
@@ -14,7 +14,6 @@
#include <boost/accumulators/framework/parameters/sample.hpp>
#include <boost/accumulators/framework/parameters/accumulator.hpp>
#include <boost/accumulators/framework/depends_on.hpp>
-#include <boost/accumulators/statistics_fwd.hpp>
#include <boost/statistics/detail/accumulator/statistics/keyword/threshold.hpp>
@@ -61,8 +60,6 @@
}//impl
-///////////////////////////////////////////////////////////////////////////////
-// tag::count_less_than
namespace tag
{
struct count_less_than
@@ -74,8 +71,6 @@
};
}
-///////////////////////////////////////////////////////////////////////////////
-// extract::count_less_than
namespace extract
{
Copied: sandbox/statistics/detail/accumulator/boost/statistics/detail/accumulator/statistics/zscore.hpp (from r56641, /sandbox/statistics/functional/boost/functional/zscore.hpp)
==============================================================================
--- /sandbox/statistics/functional/boost/functional/zscore.hpp (original)
+++ sandbox/statistics/detail/accumulator/boost/statistics/detail/accumulator/statistics/zscore.hpp 2010-02-04 19:04:37 EST (Thu, 04 Feb 2010)
@@ -1,42 +1,122 @@
//////////////////////////////////////////////////////////////////////////////
-// functional::zscore.hpp //
+// accumulator::zscore.hpp //
// //
-// (C) Copyright 2009 Erwann Rogard //
+// (C) Copyright 2010 Erwann Rogard //
// Use, modification and distribution are subject to the //
// Boost Software License, Version 1.0. (See accompanying file //
// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
//////////////////////////////////////////////////////////////////////////////
-#ifndef BOOST_FUNCTIONAL_ZSCORE_HPP_ER_2009
-#define BOOST_FUNCTIONAL_ZSCORE_HPP_ER_2009
+#ifndef BOOST_STATISTICS_DETAIL_ACCUMULATOR_ZSCORE_HPP_ER_2010
+#define BOOST_STATISTICS_DETAIL_ACCUMULATOR_ZSCORE_HPP_ER_2010
#include <cmath>
#include <boost/accumulators/accumulators.hpp>
#include <boost/accumulators/statistics/mean.hpp>
#include <boost/accumulators/statistics/variance.hpp>
-#include <boost/functional/mean_var_accumulator.hpp>
+#include <boost/accumulators/framework/extractor.hpp>
+#include <boost/accumulators/framework/accumulator_base.hpp>
+#include <boost/accumulators/framework/parameters/sample.hpp>
+#include <boost/accumulators/framework/parameters/accumulator.hpp>
+#include <boost/accumulators/framework/depends_on.hpp>
namespace boost{
-namespace functional{
+namespace statistics{
+namespace detail{
+namespace accumulator{
-template<typename T,typename A = typename mean_var_accumulator<T>::type>
-class zscore{
- public:
+namespace impl
+{
+
+ template<typename T>
+ struct zscore : public boost::accumulators::accumulator_base
+ {
+ typedef boost::accumulators::dont_care dont_care_;
+
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());
+
+ zscore(dont_care_){}
+
+ void operator ()(dont_care_)const
+ {
+ }
+
+ if(args[boost::accumulators::sample]<this->t)
+ {
+ ++this->cnt;
+ }
+
+ template<typename Args>
+ void operator ()(const Args& args)
+ typedef boost::accumulators::tag::accumulator tag_acc_;
+ typedef boost::parameter::binding<Args,tag_acc_> bind1_;
+ typedef typename bind1_::type cref_acc_;
+ cref_acc_ cref_acc = args[boost::accumulators::accumulator];
+ T x = args[boost::accumulators::sample];
+ T m = boost::accumulators::mean(cref_acc);
+ T s = boost::accumulators::variance(cref_acc);
s = std::sqrt(s);
return (x - m)/s;
- }
- const A& a()const{ return this->a_; }
- private:
- A a_;
-};
+ }
+ };
+
+}//impl
+ namespace tag
+ {
+ struct zscore
+ : boost::accumulators::depends_on<
+ boost::accumulators::tag::mean,
+ boost::accumulators::tag::variance,
+ >
+ {
+ struct impl{
+ template<typename T,typename W>
+ struct apply{
+ typedef boost::statistics::detail::accumulator::impl
+ ::zscore<T> type;
+ };
+ };
+ };
+ }
+
+ namespace result_of{
+
+ template<typename AccSet>
+ struct zscore{
+ typedef boost::statistics::detail
+ ::accumulator::tag::zscore tag_;
+ typedef typename boost::accumulators::detail::extractor_result<
+ AccSet,
+ tag_
+ >::type type;
+ };
+
+ }
+
+ namespace extract
+ {
+
+ // Usage : zscore(acc,x)
+ template<typename AccSet,typename T1>
+ typename boost::statistics::detail::accumulator::zscore
+ ::result_of::template zscore<AccSet>::type
+ statistic(AccSet const& acc,const T1& x)
+ {
+ typedef boost::statistics::detail
+ ::accumulator::tag::zscore<T1> the_tag;
+ return boost::accumulators::extract_result<the_tag>(
+ acc,
+ (
+ boost::accumulators::sample = x
+ )
+ );
+ }
+ }
+
+ using extract::zscore;
-}// functional
+}// accumulator
+}// detail
+}// statistics
}// boost
#endif
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