Boost logo

Boost-Commit :

From: eric_at_[hidden]
Date: 2008-06-24 11:54:24


Author: eric_niebler
Date: 2008-06-24 11:54:23 EDT (Tue, 24 Jun 2008)
New Revision: 46654
URL: http://svn.boost.org/trac/boost/changeset/46654

Log:
Merged revisions 46651 via svnmerge from
https://svn.boost.org/svn/boost/trunk

........
  r46651 | eric_niebler | 2008-06-24 08:40:19 -0700 (Tue, 24 Jun 2008) | 1 line
  
  make immediate the default implementation for variance and weighted_variance
........

Properties modified:
   branches/release/ (props changed)
Text files modified:
   branches/release/boost/accumulators/statistics/error_of_mean.hpp | 8 +++---
   branches/release/boost/accumulators/statistics/variance.hpp | 43 +++++++++++++++++----------------
   branches/release/boost/accumulators/statistics/weighted_variance.hpp | 29 ++++++++++++-----------
   branches/release/boost/accumulators/statistics_fwd.hpp | 12 ++++----
   branches/release/libs/accumulators/doc/accumulators.qbk | 50 ++++++++++++++++++++--------------------
   branches/release/libs/accumulators/test/variance.cpp | 8 +++---
   branches/release/libs/accumulators/test/weighted_variance.cpp | 10 ++++----
   7 files changed, 81 insertions(+), 79 deletions(-)

Modified: branches/release/boost/accumulators/statistics/error_of_mean.hpp
==============================================================================
--- branches/release/boost/accumulators/statistics/error_of_mean.hpp (original)
+++ branches/release/boost/accumulators/statistics/error_of_mean.hpp 2008-06-24 11:54:23 EDT (Tue, 24 Jun 2008)
@@ -51,20 +51,20 @@
 {
     template<>
     struct error_of<mean>
- : depends_on<variance, count>
+ : depends_on<lazy_variance, count>
     {
         /// INTERNAL ONLY
         ///
- typedef accumulators::impl::error_of_mean_impl<mpl::_1, variance> impl;
+ typedef accumulators::impl::error_of_mean_impl<mpl::_1, lazy_variance> impl;
     };
 
     template<>
     struct error_of<immediate_mean>
- : depends_on<immediate_variance, count>
+ : depends_on<variance, count>
     {
         /// INTERNAL ONLY
         ///
- typedef accumulators::impl::error_of_mean_impl<mpl::_1, immediate_variance> impl;
+ typedef accumulators::impl::error_of_mean_impl<mpl::_1, variance> impl;
     };
 }
 

Modified: branches/release/boost/accumulators/statistics/variance.hpp
==============================================================================
--- branches/release/boost/accumulators/statistics/variance.hpp (original)
+++ branches/release/boost/accumulators/statistics/variance.hpp 2008-06-24 11:54:23 EDT (Tue, 24 Jun 2008)
@@ -25,7 +25,7 @@
 
 namespace impl
 {
- //! Lazy calculaation of variance.
+ //! Lazy calculation of variance.
     /*!
         Default sample variance implementation based on the second moment \f$ M_n^{(2)} \f$ moment<2>, mean and count.
         \f[
@@ -38,13 +38,13 @@
         is the estimate of the sample mean and \f$n\f$ is the number of samples.
     */
     template<typename Sample, typename MeanFeature>
- struct variance_impl
+ struct lazy_variance_impl
       : accumulator_base
     {
         // for boost::result_of
         typedef typename numeric::functional::average<Sample, std::size_t>::result_type result_type;
 
- variance_impl(dont_care) {}
+ lazy_variance_impl(dont_care) {}
 
         template<typename Args>
         result_type result(Args const &args) const
@@ -81,14 +81,14 @@
         can be non-negligible.
     */
     template<typename Sample, typename MeanFeature, typename Tag>
- struct immediate_variance_impl
+ struct variance_impl
       : accumulator_base
     {
         // for boost::result_of
         typedef typename numeric::functional::average<Sample, std::size_t>::result_type result_type;
 
         template<typename Args>
- immediate_variance_impl(Args const &args)
+ variance_impl(Args const &args)
           : variance(numeric::average(args[sample | Sample()], numeric::one<std::size_t>::value))
         {
         }
@@ -125,53 +125,54 @@
 //
 namespace tag
 {
- struct variance
+ struct lazy_variance
       : depends_on<moment<2>, mean>
     {
         /// INTERNAL ONLY
         ///
- typedef accumulators::impl::variance_impl<mpl::_1, mean> impl;
+ typedef accumulators::impl::lazy_variance_impl<mpl::_1, mean> impl;
     };
- struct immediate_variance
+
+ struct variance
       : depends_on<count, immediate_mean>
     {
         /// INTERNAL ONLY
         ///
- typedef accumulators::impl::immediate_variance_impl<mpl::_1, mean, sample> impl;
+ typedef accumulators::impl::variance_impl<mpl::_1, mean, sample> impl;
     };
 }
 
 ///////////////////////////////////////////////////////////////////////////////
+// extract::lazy_variance
 // extract::variance
-// extract::immediate_variance
 //
 namespace extract
 {
+ extractor<tag::lazy_variance> const lazy_variance = {};
     extractor<tag::variance> const variance = {};
- extractor<tag::immediate_variance> const immediate_variance = {};
 }
 
+using extract::lazy_variance;
 using extract::variance;
-using extract::immediate_variance;
 
-// variance(lazy) -> variance
+// variance(lazy) -> lazy_variance
 template<>
 struct as_feature<tag::variance(lazy)>
 {
- typedef tag::variance type;
+ typedef tag::lazy_variance type;
 };
 
-// variance(immediate) -> immediate_variance
+// variance(immediate) -> variance
 template<>
 struct as_feature<tag::variance(immediate)>
 {
- typedef tag::immediate_variance type;
+ typedef tag::variance type;
 };
 
 // for the purposes of feature-based dependency resolution,
 // immediate_variance provides the same feature as variance
 template<>
-struct feature_of<tag::immediate_variance>
+struct feature_of<tag::lazy_variance>
   : feature_of<tag::variance>
 {
 };
@@ -195,16 +196,16 @@
 // So that immediate_variance can be automatically substituted with
 // immediate_weighted_variance when the weight parameter is non-void.
 template<>
-struct as_weighted_feature<tag::immediate_variance>
+struct as_weighted_feature<tag::lazy_variance>
 {
- typedef tag::immediate_weighted_variance type;
+ typedef tag::lazy_weighted_variance type;
 };
 
 // for the purposes of feature-based dependency resolution,
 // immediate_weighted_variance provides the same feature as immediate_variance
 template<>
-struct feature_of<tag::immediate_weighted_variance>
- : feature_of<tag::immediate_variance>
+struct feature_of<tag::lazy_weighted_variance>
+ : feature_of<tag::lazy_variance>
 {
 };
 

Modified: branches/release/boost/accumulators/statistics/weighted_variance.hpp
==============================================================================
--- branches/release/boost/accumulators/statistics/weighted_variance.hpp (original)
+++ branches/release/boost/accumulators/statistics/weighted_variance.hpp 2008-06-24 11:54:23 EDT (Tue, 24 Jun 2008)
@@ -36,14 +36,14 @@
         where \f$n\f$ is the number of samples.
     */
     template<typename Sample, typename Weight, typename MeanFeature>
- struct weighted_variance_impl
+ struct lazy_weighted_variance_impl
       : accumulator_base
     {
         typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample;
         // for boost::result_of
         typedef typename numeric::functional::average<weighted_sample, Weight>::result_type result_type;
 
- weighted_variance_impl(dont_care) {}
+ lazy_weighted_variance_impl(dont_care) {}
 
         template<typename Args>
         result_type result(Args const &args) const
@@ -68,7 +68,7 @@
         \f$n <= 1\f$.
     */
     template<typename Sample, typename Weight, typename MeanFeature, typename Tag>
- struct immediate_weighted_variance_impl
+ struct weighted_variance_impl
       : accumulator_base
     {
         typedef typename numeric::functional::multiplies<Sample, Weight>::result_type weighted_sample;
@@ -76,7 +76,7 @@
         typedef typename numeric::functional::average<weighted_sample, Weight>::result_type result_type;
 
         template<typename Args>
- immediate_weighted_variance_impl(Args const &args)
+ weighted_variance_impl(Args const &args)
           : weighted_variance(numeric::average(args[sample | Sample()], numeric::one<Weight>::value))
         {
         }
@@ -115,19 +115,20 @@
 //
 namespace tag
 {
- struct weighted_variance
+ struct lazy_weighted_variance
       : depends_on<weighted_moment<2>, weighted_mean>
     {
         /// INTERNAL ONLY
         ///
- typedef accumulators::impl::weighted_variance_impl<mpl::_1, mpl::_2, weighted_mean> impl;
+ typedef accumulators::impl::lazy_weighted_variance_impl<mpl::_1, mpl::_2, weighted_mean> impl;
     };
- struct immediate_weighted_variance
+
+ struct weighted_variance
       : depends_on<count, immediate_weighted_mean>
     {
         /// INTERNAL ONLY
         ///
- typedef accumulators::impl::immediate_weighted_variance_impl<mpl::_1, mpl::_2, immediate_weighted_mean, sample> impl;
+ typedef accumulators::impl::weighted_variance_impl<mpl::_1, mpl::_2, immediate_weighted_mean, sample> impl;
     };
 }
 
@@ -137,25 +138,25 @@
 //
 namespace extract
 {
+ extractor<tag::lazy_weighted_variance> const lazy_weighted_variance = {};
     extractor<tag::weighted_variance> const weighted_variance = {};
- extractor<tag::immediate_weighted_variance> const immediate_weighted_variance = {};
 }
 
+using extract::lazy_weighted_variance;
 using extract::weighted_variance;
-using extract::immediate_weighted_variance;
 
-// weighted_variance(lazy) -> weighted_variance
+// weighted_variance(lazy) -> lazy_weighted_variance
 template<>
 struct as_feature<tag::weighted_variance(lazy)>
 {
- typedef tag::weighted_variance type;
+ typedef tag::lazy_weighted_variance type;
 };
 
-// weighted_variance(immediate) -> immediate_weighted_variance
+// weighted_variance(immediate) -> weighted_variance
 template<>
 struct as_feature<tag::weighted_variance(immediate)>
 {
- typedef tag::immediate_weighted_variance type;
+ typedef tag::weighted_variance type;
 };
 
 ////////////////////////////////////////////////////////////////////////////

Modified: branches/release/boost/accumulators/statistics_fwd.hpp
==============================================================================
--- branches/release/boost/accumulators/statistics_fwd.hpp (original)
+++ branches/release/boost/accumulators/statistics_fwd.hpp 2008-06-24 11:54:23 EDT (Tue, 24 Jun 2008)
@@ -127,8 +127,8 @@
     struct absolute_tail_variate_means;
     template<typename LeftRight, typename VariateType, typename VariateTag>
     struct relative_tail_variate_means;
+ struct lazy_variance;
     struct variance;
- struct immediate_variance;
     template<typename VariateType, typename VariateTag>
     struct weighted_covariance;
     struct weighted_density;
@@ -175,8 +175,8 @@
     struct absolute_weighted_tail_variate_means;
     template<typename LeftRight, typename VariateType, typename VariateTag>
     struct relative_weighted_tail_variate_means;
+ struct lazy_weighted_variance;
     struct weighted_variance;
- struct immediate_weighted_variance;
     struct weighted_sum;
     template<typename VariateType, typename VariateTag>
     struct weighted_sum_of_variates;
@@ -273,10 +273,10 @@
     struct tail_variate_means_impl;
 
     template<typename Sample, typename MeanFeature>
- struct variance_impl;
+ struct lazy_variance_impl;
 
     template<typename Sample, typename MeanFeature, typename Tag>
- struct immediate_variance_impl;
+ struct variance_impl;
 
     template<typename Sample, typename Weight, typename VariateType, typename VariateTag>
     struct weighted_covariance_impl;
@@ -339,10 +339,10 @@
     struct weighted_tail_variate_means_impl;
 
     template<typename Sample, typename Weight, typename MeanFeature>
- struct weighted_variance_impl;
+ struct lazy_weighted_variance_impl;
 
     template<typename Sample, typename Weight, typename MeanFeature, typename Tag>
- struct immediate_weighted_variance_impl;
+ struct weighted_variance_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-06-24 11:54:23 EDT (Tue, 24 Jun 2008)
@@ -2338,20 +2338,20 @@
 
 [section:variance variance ['and variants]]
 
-Lazy or iterative calculation of the variance. The lazy calculation is associated with the `tag::variance`
-feature, and the iterative calculation with the `tag::immediate_variance` feature. Both can be extracted
+Lazy or iterative calculation of the variance. The lazy calculation is associated with the `tag::lazy_variance`
+feature, and the iterative calculation with the `tag::variance` feature. Both can be extracted
 using the `tag::variance()` extractor. For more implementation details, see
-[classref boost::accumulators::impl::variance_impl [^variance_impl]] and
-[classref boost::accumulators::impl::immediate_variance_impl [^immediate_variance_impl]]
+[classref boost::accumulators::impl::lazy_variance_impl [^lazy_variance_impl]] and
+[classref boost::accumulators::impl::variance_impl [^variance_impl]]
 
 [variablelist
     [[Result Type] [``
                     numeric::functional::average<_sample_type_, std::size_t>::result_type
                     ``]]
- [[Depends On] [`tag::variance` depends on `tag::moment<2>` and `tag::mean` \n
- `tag::immediate_variance` depends on `tag::count` and `tag::immediate_mean`]]
- [[Variants] [`tag::variance` (a.k.a. `tag::variance(lazy))` \n
- `tag::immediate_variance` (a.k.a. `tag::variance(immediate)`)]]
+ [[Depends On] [`tag::lazy_variance` depends on `tag::moment<2>` and `tag::mean` \n
+ `tag::variance` depends on `tag::count` and `tag::immediate_mean`]]
+ [[Variants] [`tag::lazy_variance` (a.k.a. `tag::variance(lazy))` \n
+ `tag::variance` (a.k.a. `tag::variance(immediate)`)]]
     [[Initialization Parameters] [['none]]]
     [[Accumulator Parameters] [['none]]]
     [[Extractor Parameters] [['none]]]
@@ -2361,8 +2361,8 @@
 
 [*Example]
 
- // basic lazy variance
- accumulator_set<int, stats<tag::variance > > acc1;
+ // lazy variance
+ accumulator_set<int, stats<tag::variance(lazy)> > acc1;
 
     acc1(1);
     acc1(2);
@@ -2376,7 +2376,7 @@
     BOOST_CHECK_CLOSE(2., variance(acc1), 1e-5);
 
     // immediate variance
- accumulator_set<int, stats<tag::variance(immediate) > > acc2;
+ accumulator_set<int, stats<tag::variance> > acc2;
 
     acc2(1);
     acc2(2);
@@ -2388,11 +2388,10 @@
     BOOST_CHECK_CLOSE(3., mean(acc2), 1e-5);
     BOOST_CHECK_CLOSE(2., variance(acc2), 1e-5);
 
-
 [*See also]
 
+* [classref boost::accumulators::impl::lazy_variance_impl [^lazy_variance_impl]]
 * [classref boost::accumulators::impl::variance_impl [^variance_impl]]
-* [classref boost::accumulators::impl::immediate_variance_impl [^immediate_variance_impl]]
 * [link accumulators.user_s_guide.the_statistical_accumulators_library.count [^count]]
 * [link accumulators.user_s_guide.the_statistical_accumulators_library.mean [^mean]]
 * [link accumulators.user_s_guide.the_statistical_accumulators_library.moment [^moment]]
@@ -3095,11 +3094,11 @@
 
 [section:weighted_variance weighted_variance ['and variants]]
 
-Lazy or iterative calculation of the weighted variance. The lazy calculation is associated with the `tag::weighted_variance`
-feature, and the iterative calculation with the `tag::immediate_weighted_variance` feature. Both can be extracted
+Lazy or iterative calculation of the weighted variance. The lazy calculation is associated with the `tag::lazy_weighted_variance`
+feature, and the iterative calculation with the `tag::weighted_variance` feature. Both can be extracted
 using the `tag::weighted_variance()` extractor. For more implementation details, see
-[classref boost::accumulators::impl::weighted_variance_impl [^weighted_variance_impl]] and
-[classref boost::accumulators::impl::immediate_weighted_variance_impl [^immediate_weighted_variance_impl]]
+[classref boost::accumulators::impl::lazy_weighted_variance_impl [^lazy_weighted_variance_impl]] and
+[classref boost::accumulators::impl::weighted_variance_impl [^weighted_variance_impl]]
 
 [variablelist
     [[Result Type] [``
@@ -3108,10 +3107,10 @@
                       , std::size_t
>::result_type
                     ``]]
- [[Depends On] [`tag::weighted_variance` depends on `tag::weighted_moment<2>` and `tag::weighted_mean` \n
- `tag::immediate_weighted_variance` depends on `tag::count` and `tag::immediate_weighted_mean`]]
- [[Variants] [`tag::weighted_variance` (a.k.a. `tag::weighted_variance(lazy))` \n
- `tag::immediate_weighted_variance` (a.k.a. `tag::weighted_variance(immediate)`)]]
+ [[Depends On] [`tag::lazy_weighted_variance` depends on `tag::weighted_moment<2>` and `tag::weighted_mean` \n
+ `tag::weighted_variance` depends on `tag::count` and `tag::immediate_weighted_mean`]]
+ [[Variants] [`tag::lazy_weighted_variance` (a.k.a. `tag::weighted_variance(lazy))` \n
+ `tag::weighted_variance` (a.k.a. `tag::weighted_variance(immediate)`)]]
     [[Initialization Parameters] [['none]]]
     [[Accumulator Parameters] [`weight`]]
     [[Extractor Parameters] [['none]]]
@@ -3121,8 +3120,8 @@
 
 [*Example]
 
- // basic lazy weighted_variance
- accumulator_set<int, stats<tag::weighted_variance>, int> acc1;
+ // lazy weighted_variance
+ accumulator_set<int, stats<tag::weighted_variance(lazy)>, int> acc1;
 
     acc1(1, weight = 2); // 2
     acc1(2, weight = 3); // 6
@@ -3137,7 +3136,8 @@
     BOOST_CHECK_CLOSE(10.1818182, weighted_moment<2>(acc1), 1e-5);
     BOOST_CHECK_CLOSE(1.7190083, weighted_variance(acc1), 1e-5);
 
- accumulator_set<int, stats<tag::weighted_variance(immediate)>, int> acc2;
+ // immediate weighted_variance
+ accumulator_set<int, stats<tag::weighted_variance>, int> acc2;
 
     acc2(1, weight = 2);
     acc2(2, weight = 3);
@@ -3171,8 +3171,8 @@
 
 [*See also]
 
+* [classref boost::accumulators::impl::lazy_weighted_variance_impl [^lazy_weighted_variance_impl]]
 * [classref boost::accumulators::impl::weighted_variance_impl [^weighted_variance_impl]]
-* [classref boost::accumulators::impl::immediate_weighted_variance_impl [^immediate_weighted_variance_impl]]
 * [link accumulators.user_s_guide.the_statistical_accumulators_library.count [^count]]
 * [link accumulators.user_s_guide.the_statistical_accumulators_library.weighted_mean [^weighted_mean]]
 * [link accumulators.user_s_guide.the_statistical_accumulators_library.weighted_moment [^weighted_moment]]

Modified: branches/release/libs/accumulators/test/variance.cpp
==============================================================================
--- branches/release/libs/accumulators/test/variance.cpp (original)
+++ branches/release/libs/accumulators/test/variance.cpp 2008-06-24 11:54:23 EDT (Tue, 24 Jun 2008)
@@ -27,8 +27,8 @@
     // >> sum(samples .* samples) / length(samples) - mean(samples)^2
     // ans = 2
 
- // basic lazy variance
- accumulator_set<int, stats<tag::variance > > acc1;
+ // lazy variance, now lazy with syntactic sugar, thanks to Eric
+ accumulator_set<int, stats<tag::variance(lazy)> > acc1;
 
     acc1(1);
     acc1(2);
@@ -41,8 +41,8 @@
     BOOST_CHECK_CLOSE(11., moment<2>(acc1), 1e-5);
     BOOST_CHECK_CLOSE(2., variance(acc1), 1e-5);
 
- // immediate variance, now immediate with syntactic sugar, thanks to Eric
- accumulator_set<int, stats<tag::variance(immediate) > > acc2;
+ // immediate variance
+ accumulator_set<int, stats<tag::variance> > acc2;
 
     acc2(1);
     acc2(2);

Modified: branches/release/libs/accumulators/test/weighted_variance.cpp
==============================================================================
--- branches/release/libs/accumulators/test/weighted_variance.cpp (original)
+++ branches/release/libs/accumulators/test/weighted_variance.cpp 2008-06-24 11:54:23 EDT (Tue, 24 Jun 2008)
@@ -19,8 +19,8 @@
 //
 void test_stat()
 {
- // basic lazy weighted_variance
- accumulator_set<int, stats<tag::weighted_variance>, int> acc1;
+ // lazy weighted_variance
+ accumulator_set<int, stats<tag::weighted_variance(lazy)>, int> acc1;
 
     acc1(1, weight = 2); // 2
     acc1(2, weight = 3); // 6
@@ -35,7 +35,7 @@
     BOOST_CHECK_CLOSE(10.1818182, weighted_moment<2>(acc1), 1e-5);
     BOOST_CHECK_CLOSE(1.7190083, weighted_variance(acc1), 1e-5);
 
- accumulator_set<int, stats<tag::weighted_variance(immediate)>, int> acc2;
+ accumulator_set<int, stats<tag::weighted_variance>, int> acc2;
 
     acc2(1, weight = 2);
     acc2(2, weight = 3);
@@ -54,8 +54,8 @@
     boost::normal_distribution<> mean_sigma(0,1);
     boost::variate_generator<boost::lagged_fibonacci607&, boost::normal_distribution<> > normal(rng, mean_sigma);
 
- accumulator_set<double, stats<tag::weighted_variance>, double > acc_lazy;
- accumulator_set<double, stats<tag::weighted_variance(immediate)>, double > acc_immediate;
+ accumulator_set<double, stats<tag::weighted_variance(lazy)>, double > acc_lazy;
+ accumulator_set<double, stats<tag::weighted_variance>, double > acc_immediate;
 
     for (std::size_t i=0; i<10000; ++i)
     {


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