|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r50414 - in branches/release: . boost/accumulators boost/accumulators/statistics libs/accumulators/doc libs/accumulators/test
From: eric_at_[hidden]
Date: 2008-12-30 14:30:46
Author: eric_niebler
Date: 2008-12-30 14:30:45 EST (Tue, 30 Dec 2008)
New Revision: 50414
URL: http://svn.boost.org/trac/boost/changeset/50414
Log:
Merged revisions 50392 via svnmerge from
https://svn.boost.org/svn/boost/trunk
........
r50392 | eric_niebler | 2008-12-27 17:44:00 -0800 (Sat, 27 Dec 2008) | 1 line
add rolling_window, rolling_count, rolling_sum and rolling_mean
........
Added:
branches/release/boost/accumulators/statistics/rolling_count.hpp
- copied unchanged from r50392, /trunk/boost/accumulators/statistics/rolling_count.hpp
branches/release/boost/accumulators/statistics/rolling_mean.hpp
- copied unchanged from r50392, /trunk/boost/accumulators/statistics/rolling_mean.hpp
branches/release/boost/accumulators/statistics/rolling_sum.hpp
- copied unchanged from r50392, /trunk/boost/accumulators/statistics/rolling_sum.hpp
branches/release/boost/accumulators/statistics/rolling_window.hpp
- copied unchanged from r50392, /trunk/boost/accumulators/statistics/rolling_window.hpp
branches/release/libs/accumulators/test/rolling_count.cpp
- copied unchanged from r50392, /trunk/libs/accumulators/test/rolling_count.cpp
branches/release/libs/accumulators/test/rolling_mean.cpp
- copied, changed from r50392, /trunk/libs/accumulators/test/rolling_mean.cpp
branches/release/libs/accumulators/test/rolling_sum.cpp
- copied unchanged from r50392, /trunk/libs/accumulators/test/rolling_sum.cpp
Properties modified:
branches/release/ (props changed)
Text files modified:
branches/release/boost/accumulators/statistics_fwd.hpp | 18 +++++
branches/release/libs/accumulators/doc/accumulators.qbk | 140 ++++++++++++++++++++++++++++++++++++++++
branches/release/libs/accumulators/test/Jamfile.v2 | 3
branches/release/libs/accumulators/test/rolling_mean.cpp | 2
4 files changed, 162 insertions(+), 1 deletions(-)
Modified: branches/release/boost/accumulators/statistics_fwd.hpp
==============================================================================
--- branches/release/boost/accumulators/statistics_fwd.hpp (original)
+++ branches/release/boost/accumulators/statistics_fwd.hpp 2008-12-30 14:30:45 EST (Tue, 30 Dec 2008)
@@ -180,6 +180,11 @@
struct weighted_sum;
template<typename VariateType, typename VariateTag>
struct weighted_sum_of_variates;
+ struct rolling_window_plus1;
+ struct rolling_window;
+ struct rolling_sum;
+ struct rolling_count;
+ struct rolling_mean;
} // namespace tag
namespace impl
@@ -344,7 +349,20 @@
template<typename Sample, typename Weight, typename MeanFeature, typename Tag>
struct weighted_variance_impl;
+ template<typename Sample>
+ struct rolling_window_plus1_impl;
+
+ template<typename Sample>
+ struct rolling_window_impl;
+
+ template<typename Sample>
+ struct rolling_sum_impl;
+
+ template<typename Sample>
+ struct rolling_count_impl;
+ template<typename Sample>
+ struct rolling_mean_impl;
} // namespace impl
///////////////////////////////////////////////////////////////////////////////
Modified: branches/release/libs/accumulators/doc/accumulators.qbk
==============================================================================
--- branches/release/libs/accumulators/doc/accumulators.qbk (original)
+++ branches/release/libs/accumulators/doc/accumulators.qbk 2008-12-30 14:30:45 EST (Tue, 30 Dec 2008)
@@ -2023,6 +2023,146 @@
[endsect]
+[section:rolling_count rolling_count]
+
+The rolling count is the current number of elements in the rolling window.
+
+[variablelist
+ [[Result Type] [``std::size_t``]]
+ [[Depends On] [`rolling_window_plus1`]]
+ [[Variants] [['none]]]
+ [[Initialization Parameters] [`tag::rolling_window::window_size`]]
+ [[Accumulator Parameters] [['none]]]
+ [[Extractor Parameters] [['none]]]
+ [[Accumulator Complexity] [O(1)]]
+ [[Extractor Complexity] [O(1)]]
+]
+
+[*Header]
+[def _ROLLING_COUNT_HPP_ [headerref boost/accumulators/statistics/rolling_count.hpp]]
+
+ #include <_ROLLING_COUNT_HPP_>
+
+[*Example]
+
+ accumulator_set<int, stats<tag::rolling_count> > acc(tag::rolling_window::window_size = 3);
+
+ BOOST_CHECK_EQUAL(0u, rolling_count(acc));
+
+ acc(1);
+ BOOST_CHECK_EQUAL(1u, rolling_count(acc));
+
+ acc(1);
+ BOOST_CHECK_EQUAL(2u, rolling_count(acc));
+
+ acc(1);
+ BOOST_CHECK_EQUAL(3u, rolling_count(acc));
+
+ acc(1);
+ BOOST_CHECK_EQUAL(3u, rolling_count(acc));
+
+ acc(1);
+ BOOST_CHECK_EQUAL(3u, rolling_count(acc));
+
+[*See also]
+
+* [classref boost::accumulators::impl::rolling_count_impl [^rolling_count_impl]]
+
+[endsect]
+
+[section:rolling_sum rolling_sum]
+
+The rolling sum is the sum of the last /N/ samples.
+
+[variablelist
+ [[Result Type] [``_sample_type_``]]
+ [[Depends On] [`rolling_window_plus1`]]
+ [[Variants] [['none]]]
+ [[Initialization Parameters] [`tag::rolling_window::window_size`]]
+ [[Accumulator Parameters] [['none]]]
+ [[Extractor Parameters] [['none]]]
+ [[Accumulator Complexity] [O(1)]]
+ [[Extractor Complexity] [O(1)]]
+]
+
+[*Header]
+[def _ROLLING_SUM_HPP_ [headerref boost/accumulators/statistics/rolling_sum.hpp]]
+
+ #include <_ROLLING_SUM_HPP_>
+
+[*Example]
+
+ accumulator_set<int, stats<tag::rolling_sum> > acc(tag::rolling_window::window_size = 3);
+
+ BOOST_CHECK_EQUAL(0, rolling_sum(acc));
+
+ acc(1);
+ BOOST_CHECK_EQUAL(1, rolling_sum(acc));
+
+ acc(2);
+ BOOST_CHECK_EQUAL(3, rolling_sum(acc));
+
+ acc(3);
+ BOOST_CHECK_EQUAL(6, rolling_sum(acc));
+
+ acc(4);
+ BOOST_CHECK_EQUAL(9, rolling_sum(acc));
+
+ acc(5);
+ BOOST_CHECK_EQUAL(12, rolling_sum(acc));
+
+[*See also]
+
+* [classref boost::accumulators::impl::rolling_sum_impl [^rolling_sum_impl]]
+
+[endsect]
+
+[section:rolling_mean rolling_mean]
+
+The rolling mean is the mean over the last /N/ samples. It is computed by dividing
+the rolling sum by the rolling count.
+
+[variablelist
+ [[Result Type] [``
+ numeric::functional::average<_sample_type_, std::size_t>::result_type
+ ``]]
+ [[Depends On] [`rolling_sum` \n `rolling_count`]]
+ [[Variants] [['none]]]
+ [[Initialization Parameters] [`tag::rolling_window::window_size`]]
+ [[Accumulator Parameters] [['none]]]
+ [[Extractor Parameters] [['none]]]
+ [[Accumulator Complexity] [O(1)]]
+ [[Extractor Complexity] [O(1)]]
+]
+
+[*Header]
+[def _ROLLING_MEAN_HPP_ [headerref boost/accumulators/statistics/rolling_mean.hpp]]
+
+ #include <_ROLLING_MEAN_HPP_>
+
+[*Example]
+
+ accumulator_set<int, stats<tag::rolling_mean> > acc(tag::rolling_window::window_size = 5);
+
+ acc(1);
+ acc(2);
+ acc(3);
+
+ BOOST_CHECK_CLOSE( rolling_mean(acc), 2.0, 1e-6 );
+
+ acc(4);
+ acc(5);
+ acc(6);
+ acc(7);
+
+ BOOST_CHECK_CLOSE( rolling_mean(acc), 5.0, 1e-6 );
+
+[*See also]
+
+* [classref boost::accumulators::impl::rolling_mean_impl [^rolling_mean_impl]]
+
+[endsect]
+
[section:skewness skewness]
The skewness of a sample distribution is defined as the ratio of the 3rd central moment and the [^3/2]-th power
Modified: branches/release/libs/accumulators/test/Jamfile.v2
==============================================================================
--- branches/release/libs/accumulators/test/Jamfile.v2 (original)
+++ branches/release/libs/accumulators/test/Jamfile.v2 2008-12-30 14:30:45 EST (Tue, 30 Dec 2008)
@@ -45,6 +45,9 @@
[ run p_square_cumulative_distribution.cpp ]
[ run p_square_quantile.cpp ]
[ run reference.cpp ]
+ [ run rolling_count.cpp ]
+ [ run rolling_sum.cpp ]
+ [ run rolling_mean.cpp ]
[ run skewness.cpp ]
[ run sum.cpp ]
[ run tail.cpp ]
Copied: branches/release/libs/accumulators/test/rolling_mean.cpp (from r50392, /trunk/libs/accumulators/test/rolling_mean.cpp)
==============================================================================
--- /trunk/libs/accumulators/test/rolling_mean.cpp (original)
+++ branches/release/libs/accumulators/test/rolling_mean.cpp 2008-12-30 14:30:45 EST (Tue, 30 Dec 2008)
@@ -40,7 +40,7 @@
BOOST_CHECK_CLOSE(1.5, rolling_mean(acc), 1e-5);
acc(3);
- BOOST_CHECK_CLOSE(2, rolling_mean(acc), 1e-5);
+ BOOST_CHECK_CLOSE(2., rolling_mean(acc), 1e-5);
acc(4);
BOOST_CHECK_CLOSE(2.5, rolling_mean(acc), 1e-5);
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