|
Boost-Commit : |
From: eric_at_[hidden]
Date: 2008-01-08 13:43:46
Author: eric_niebler
Date: 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
New Revision: 42620
URL: http://svn.boost.org/trac/boost/changeset/42620
Log:
fix signed/unsigned warnings, clean up trailing whitespace
Text files modified:
trunk/libs/accumulators/test/covariance.cpp | 16 ++++++++--------
trunk/libs/accumulators/test/extended_p_square.cpp | 2 +-
trunk/libs/accumulators/test/extended_p_square_quantile.cpp | 4 ++--
trunk/libs/accumulators/test/kurtosis.cpp | 14 +++++++-------
trunk/libs/accumulators/test/mean.cpp | 2 +-
trunk/libs/accumulators/test/median.cpp | 10 +++++-----
trunk/libs/accumulators/test/p_square_cumulative_distribution.cpp | 16 ++++++++--------
trunk/libs/accumulators/test/p_square_quantile.cpp | 10 +++++-----
trunk/libs/accumulators/test/pot_quantile.cpp | 18 +++++++++---------
trunk/libs/accumulators/test/reference.cpp | 14 +++++++-------
trunk/libs/accumulators/test/skewness.cpp | 14 +++++++-------
trunk/libs/accumulators/test/tail_mean.cpp | 10 +++++-----
trunk/libs/accumulators/test/tail_quantile.cpp | 16 ++++++++--------
trunk/libs/accumulators/test/tail_variate_means.cpp | 26 +++++++++++++-------------
trunk/libs/accumulators/test/variance.cpp | 2 +-
trunk/libs/accumulators/test/weighted_covariance.cpp | 18 +++++++++---------
trunk/libs/accumulators/test/weighted_extended_p_square.cpp | 16 ++++++++--------
trunk/libs/accumulators/test/weighted_kurtosis.cpp | 14 +++++++-------
trunk/libs/accumulators/test/weighted_mean.cpp | 6 +++---
trunk/libs/accumulators/test/weighted_median.cpp | 14 +++++++-------
trunk/libs/accumulators/test/weighted_moment.cpp | 6 +++---
trunk/libs/accumulators/test/weighted_p_square_cum_dist.cpp | 26 +++++++++++++-------------
trunk/libs/accumulators/test/weighted_p_square_quantile.cpp | 10 +++++-----
trunk/libs/accumulators/test/weighted_pot_quantile.cpp | 22 +++++++++++-----------
trunk/libs/accumulators/test/weighted_skewness.cpp | 14 +++++++-------
trunk/libs/accumulators/test/weighted_tail_mean.cpp | 12 ++++++------
trunk/libs/accumulators/test/weighted_tail_quantile.cpp | 14 +++++++-------
trunk/libs/accumulators/test/weighted_tail_variate_means.cpp | 24 ++++++++++++------------
trunk/libs/accumulators/test/weighted_variance.cpp | 12 ++++++------
29 files changed, 191 insertions(+), 191 deletions(-)
Modified: trunk/libs/accumulators/test/covariance.cpp
==============================================================================
--- trunk/libs/accumulators/test/covariance.cpp (original)
+++ trunk/libs/accumulators/test/covariance.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -24,12 +24,12 @@
std::vector<double> dummy;
dummy.push_back(0);
dummy.push_back(0);
-
+
accumulator_set<double, stats<tag::covariance<double, tag::covariate1> > > acc;
accumulator_set<std::vector<double>, stats<tag::covariance<double, tag::covariate1> > > acc2(sample = dummy);
accumulator_set<double, stats<tag::covariance<std::vector<double>, tag::covariate1> > > acc3(covariate1 = dummy);
accumulator_set<std::vector<double>, stats<tag::covariance<std::vector<double>, tag::covariate1> > > acc4(sample = dummy, covariate1 = dummy);
-
+
std::vector<double> a;
a.push_back(1.);
a.push_back(2.);
@@ -42,7 +42,7 @@
std::vector<double> d;
d.push_back(4.);
d.push_back(2.);
-
+
// double - double
{
acc(1., covariate1 = 2.);
@@ -50,7 +50,7 @@
acc(2., covariate1 = 3.);
acc(6., covariate1 = 1.);
}
-
+
// vector - double
{
acc2(a, covariate1 = 1.);
@@ -58,7 +58,7 @@
acc2(c, covariate1 = 2.);
acc2(d, covariate1 = 6.);
}
-
+
// double - vector
{
acc3(1., covariate1 = a);
@@ -66,7 +66,7 @@
acc3(2., covariate1 = c);
acc3(6., covariate1 = d);
}
-
+
// vector - vector
{
acc4(a, covariate1 = b);
@@ -74,9 +74,9 @@
acc4(a, covariate1 = c);
acc4(d, covariate1 = b);
}
-
+
double epsilon = 1e-6;
-
+
BOOST_CHECK_CLOSE((covariance(acc)), -1.75, epsilon);
BOOST_CHECK_CLOSE((covariance(acc2))[0], 1.75, epsilon);
BOOST_CHECK_CLOSE((covariance(acc2))[1], -1.125, epsilon);
Modified: trunk/libs/accumulators/test/extended_p_square.cpp
==============================================================================
--- trunk/libs/accumulators/test/extended_p_square.cpp (original)
+++ trunk/libs/accumulators/test/extended_p_square.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -53,7 +53,7 @@
BOOST_CHECK_CLOSE(extended_p_square(acc)[0], probs[0], 25);
BOOST_CHECK_CLOSE(extended_p_square(acc)[1], probs[1], 10);
BOOST_CHECK_CLOSE(extended_p_square(acc)[2], probs[2], 5);
-
+
for (std::size_t i=3; i<probs.size(); ++i)
{
BOOST_CHECK_CLOSE(extended_p_square(acc)[i], probs[i], epsilon);
Modified: trunk/libs/accumulators/test/extended_p_square_quantile.cpp
==============================================================================
--- trunk/libs/accumulators/test/extended_p_square_quantile.cpp (original)
+++ trunk/libs/accumulators/test/extended_p_square_quantile.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -53,7 +53,7 @@
accumulator_t_weighted acc_weighted(extended_p_square_probabilities = probs);
accumulator_t_quadratic acc2(extended_p_square_probabilities = probs);
accumulator_t_weighted_quadratic acc_weighted2(extended_p_square_probabilities = probs);
-
+
for (int i=0; i<10000; ++i)
{
double sample = rng();
@@ -62,7 +62,7 @@
acc_weighted(sample, weight = 1.);
acc_weighted2(sample, weight = 1.);
}
-
+
for (std::size_t i = 0; i < probs.size() - 1; ++i)
{
BOOST_CHECK_CLOSE(
Modified: trunk/libs/accumulators/test/kurtosis.cpp
==============================================================================
--- trunk/libs/accumulators/test/kurtosis.cpp (original)
+++ trunk/libs/accumulators/test/kurtosis.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -26,29 +26,29 @@
{
// tolerance in %
// double epsilon = 1;
-
+
accumulator_set<double, stats<tag::kurtosis > > acc1;
accumulator_set<int, stats<tag::kurtosis > > acc2;
-
+
// two random number generators
boost::lagged_fibonacci607 rng;
boost::normal_distribution<> mean_sigma(0,1);
boost::variate_generator<boost::lagged_fibonacci607&, boost::normal_distribution<> > normal(rng, mean_sigma);
-
+
for (std::size_t i=0; i<100000; ++i)
{
acc1(normal());
}
-
+
// This check fails because epsilon is relative and not absolute
- // BOOST_CHECK_CLOSE( kurtosis(acc1), 0., epsilon );
-
+ // BOOST_CHECK_CLOSE( kurtosis(acc1), 0., epsilon );
+
acc2(2);
acc2(7);
acc2(4);
acc2(9);
acc2(3);
-
+
BOOST_CHECK_EQUAL( mean(acc2), 5 );
BOOST_CHECK_EQUAL( moment<2>(acc2), 159./5. );
BOOST_CHECK_EQUAL( moment<3>(acc2), 1171./5. );
Modified: trunk/libs/accumulators/test/mean.cpp
==============================================================================
--- trunk/libs/accumulators/test/mean.cpp (original)
+++ trunk/libs/accumulators/test/mean.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -38,7 +38,7 @@
BOOST_CHECK_EQUAL(1u, count(acc));
BOOST_CHECK_EQUAL(1, sum(acc));
BOOST_CHECK_CLOSE(3., (mean_of_variates<int, tag::covariate1>(acc)), 1e-5);
-
+
acc(0, covariate1 = 4);
BOOST_CHECK_CLOSE(0.5, mean(acc), 1e-5);
BOOST_CHECK_EQUAL(2u, count(acc));
Modified: trunk/libs/accumulators/test/median.cpp
==============================================================================
--- trunk/libs/accumulators/test/median.cpp (original)
+++ trunk/libs/accumulators/test/median.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -24,13 +24,13 @@
boost::lagged_fibonacci607 rng;
boost::normal_distribution<> mean_sigma(mu,1);
boost::variate_generator<boost::lagged_fibonacci607&, boost::normal_distribution<> > normal(rng, mean_sigma);
-
+
accumulator_set<double, stats<tag::median(with_p_square_quantile) > > acc;
- accumulator_set<double, stats<tag::median(with_density) > >
+ accumulator_set<double, stats<tag::median(with_density) > >
acc_dens( density_cache_size = 10000, density_num_bins = 1000 );
- accumulator_set<double, stats<tag::median(with_p_square_cumulative_distribution) > >
+ accumulator_set<double, stats<tag::median(with_p_square_cumulative_distribution) > >
acc_cdist( p_square_cumulative_distribution_num_cells = 100 );
-
+
for (std::size_t i=0; i<100000; ++i)
{
double sample = normal();
@@ -38,7 +38,7 @@
acc_dens(sample);
acc_cdist(sample);
}
-
+
BOOST_CHECK_CLOSE(1., median(acc), 1.);
BOOST_CHECK_CLOSE(1., median(acc_dens), 1.);
BOOST_CHECK_CLOSE(1., median(acc_cdist), 3.);
Modified: trunk/libs/accumulators/test/p_square_cumulative_distribution.cpp
==============================================================================
--- trunk/libs/accumulators/test/p_square_cumulative_distribution.cpp (original)
+++ trunk/libs/accumulators/test/p_square_cumulative_distribution.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -43,28 +43,28 @@
double epsilon = 3;
typedef accumulator_set<double, stats<tag::p_square_cumulative_distribution> > accumulator_t;
-
+
accumulator_t acc(p_square_cumulative_distribution_num_cells = 100);
-
+
// two random number generators
boost::lagged_fibonacci607 rng;
boost::normal_distribution<> mean_sigma(0,1);
boost::variate_generator<boost::lagged_fibonacci607&, boost::normal_distribution<> > normal(rng, mean_sigma);
-
+
for (std::size_t i=0; i<100000; ++i)
{
acc(normal());
}
-
+
typedef iterator_range<std::vector<std::pair<double, double> >::iterator > histogram_type;
histogram_type histogram = p_square_cumulative_distribution(acc);
-
+
for (std::size_t i = 0; i < histogram.size(); ++i)
- {
+ {
// problem with small results: epsilon is relative (in percent), not absolute!
- if ( histogram[i].second > 0.001 )
+ if ( histogram[i].second > 0.001 )
BOOST_CHECK_CLOSE( 0.5 * (1.0 + my_erf( histogram[i].first / sqrt(2.0) )), histogram[i].second, epsilon );
- }
+ }
}
///////////////////////////////////////////////////////////////////////////////
Modified: trunk/libs/accumulators/test/p_square_quantile.cpp
==============================================================================
--- trunk/libs/accumulators/test/p_square_quantile.cpp (original)
+++ trunk/libs/accumulators/test/p_square_quantile.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -28,10 +28,10 @@
// tolerance in %
double epsilon = 1;
-
+
// a random number generator
boost::lagged_fibonacci607 rng;
-
+
accumulator_t acc0(quantile_probability = 0.001);
accumulator_t acc1(quantile_probability = 0.01 );
accumulator_t acc2(quantile_probability = 0.1 );
@@ -41,7 +41,7 @@
accumulator_t acc6(quantile_probability = 0.9 );
accumulator_t acc7(quantile_probability = 0.99 );
accumulator_t acc8(quantile_probability = 0.999);
-
+
for (int i=0; i<100000; ++i)
{
double sample = rng();
@@ -55,7 +55,7 @@
acc7(sample);
acc8(sample);
}
-
+
BOOST_CHECK_CLOSE( p_square_quantile(acc0), 0.001, 15*epsilon );
BOOST_CHECK_CLOSE( p_square_quantile(acc1), 0.01 , 5*epsilon );
BOOST_CHECK_CLOSE( p_square_quantile(acc2), 0.1 , epsilon );
@@ -64,7 +64,7 @@
BOOST_CHECK_CLOSE( p_square_quantile(acc5), 0.75 , epsilon );
BOOST_CHECK_CLOSE( p_square_quantile(acc6), 0.9 , epsilon );
BOOST_CHECK_CLOSE( p_square_quantile(acc7), 0.99 , epsilon );
- BOOST_CHECK_CLOSE( p_square_quantile(acc8), 0.999, epsilon );
+ BOOST_CHECK_CLOSE( p_square_quantile(acc8), 0.999, epsilon );
}
///////////////////////////////////////////////////////////////////////////////
Modified: trunk/libs/accumulators/test/pot_quantile.cpp
==============================================================================
--- trunk/libs/accumulators/test/pot_quantile.cpp (original)
+++ trunk/libs/accumulators/test/pot_quantile.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -34,7 +34,7 @@
boost::exponential_distribution<> lambda(1);
boost::variate_generator<boost::lagged_fibonacci607&, boost::normal_distribution<> > normal(rng, mean_sigma);
boost::variate_generator<boost::lagged_fibonacci607&, boost::exponential_distribution<> > exponential(rng, lambda);
-
+
accumulator_set<double, stats<tag::pot_quantile<right>(with_threshold_value)> > acc1(
pot_threshold_value = 3.
);
@@ -49,7 +49,7 @@
left_tail_cache_size = 2000
, pot_threshold_probability = 0.01
);
-
+
accumulator_set<double, stats<tag::pot_quantile<right>(with_threshold_value)> > acc5(
pot_threshold_value = 5.
);
@@ -57,7 +57,7 @@
right_tail_cache_size = 2000
, pot_threshold_probability = 0.995
);
-
+
for (std::size_t i = 0; i < 100000; ++i)
{
double sample = normal();
@@ -66,21 +66,21 @@
acc3(sample);
acc4(sample);
}
-
+
for (std::size_t i = 0; i < 100000; ++i)
{
double sample = exponential();
acc5(sample);
acc6(sample);
}
-
+
BOOST_CHECK_CLOSE( quantile(acc1, quantile_probability = 0.999), 3.090232, epsilon );
- BOOST_CHECK_CLOSE( quantile(acc2, quantile_probability = 0.999), 3.090232, epsilon );
+ BOOST_CHECK_CLOSE( quantile(acc2, quantile_probability = 0.999), 3.090232, epsilon );
BOOST_CHECK_CLOSE( quantile(acc3, quantile_probability = 0.001), -3.090232, epsilon );
- BOOST_CHECK_CLOSE( quantile(acc4, quantile_probability = 0.001), -3.090232, epsilon );
-
+ BOOST_CHECK_CLOSE( quantile(acc4, quantile_probability = 0.001), -3.090232, epsilon );
+
BOOST_CHECK_CLOSE( quantile(acc5, quantile_probability = 0.999), 6.908, epsilon );
- BOOST_CHECK_CLOSE( quantile(acc6, quantile_probability = 0.999), 6.908, epsilon );
+ BOOST_CHECK_CLOSE( quantile(acc6, quantile_probability = 0.999), 6.908, epsilon );
}
///////////////////////////////////////////////////////////////////////////////
Modified: trunk/libs/accumulators/test/reference.cpp
==============================================================================
--- trunk/libs/accumulators/test/reference.cpp (original)
+++ trunk/libs/accumulators/test/reference.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -52,9 +52,9 @@
sum_acc(1);
sum_acc(2); // sum is now 3 for both
-
- BOOST_CHECK_EQUAL(sum(acc_with_ref), sum(sum_acc));
- BOOST_CHECK_EQUAL(sum(acc_with_ref), 3);
+
+ BOOST_CHECK_EQUAL(sum(acc_with_ref), sum(sum_acc));
+ BOOST_CHECK_EQUAL(sum(acc_with_ref), 3);
}
///////////////////////////////////////////////////////////////////////////////
@@ -69,15 +69,15 @@
, stats<
tag::mean
// make sum external and hold a reference to it
- , tag::external<tag::sum, my::tag::sum_acc, sum_acc_type>
+ , tag::external<tag::sum, my::tag::sum_acc, sum_acc_type>
>
> acc_with_ref(my::sum_acc = sum_acc); // initialize the reference sum
sum_acc(1);
sum_acc(2); // sum is now 3 for both
-
- BOOST_CHECK_EQUAL(sum(acc_with_ref), sum(sum_acc));
- BOOST_CHECK_EQUAL(sum(acc_with_ref), 3);
+
+ BOOST_CHECK_EQUAL(sum(acc_with_ref), sum(sum_acc));
+ BOOST_CHECK_EQUAL(sum(acc_with_ref), 3);
}
///////////////////////////////////////////////////////////////////////////////
Modified: trunk/libs/accumulators/test/skewness.cpp
==============================================================================
--- trunk/libs/accumulators/test/skewness.cpp (original)
+++ trunk/libs/accumulators/test/skewness.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -26,29 +26,29 @@
{
// tolerance in %
// double epsilon = 1;
-
+
accumulator_set<double, stats<tag::skewness > > acc1;
accumulator_set<int, stats<tag::skewness > > acc2;
-
+
// two random number generators
boost::lagged_fibonacci607 rng;
boost::normal_distribution<> mean_sigma(0,1);
boost::variate_generator<boost::lagged_fibonacci607&, boost::normal_distribution<> > normal(rng, mean_sigma);
-
+
for (std::size_t i=0; i<100000; ++i)
{
acc1(normal());
}
-
+
// This check fails because epsilon is relative and not absolute
- // BOOST_CHECK_CLOSE( skewness(acc1), 0., epsilon );
-
+ // BOOST_CHECK_CLOSE( skewness(acc1), 0., epsilon );
+
acc2(2);
acc2(7);
acc2(4);
acc2(9);
acc2(3);
-
+
BOOST_CHECK_EQUAL( mean(acc2), 5 );
BOOST_CHECK_EQUAL( moment<2>(acc2), 159./5. );
BOOST_CHECK_EQUAL( moment<3>(acc2), 1171./5. );
Modified: trunk/libs/accumulators/test/tail_mean.cpp
==============================================================================
--- trunk/libs/accumulators/test/tail_mean.cpp (original)
+++ trunk/libs/accumulators/test/tail_mean.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -27,10 +27,10 @@
{
// tolerance in %
double epsilon = 1;
-
+
std::size_t n = 100000; // number of MC steps
std::size_t c = 10000; // cache size
-
+
typedef accumulator_set<double, stats<tag::non_coherent_tail_mean<right>, tag::tail_quantile<right> > > accumulator_t_right1;
typedef accumulator_set<double, stats<tag::non_coherent_tail_mean<left>, tag::tail_quantile<left> > > accumulator_t_left1;
typedef accumulator_set<double, stats<tag::coherent_tail_mean<right>, tag::tail_quantile<right> > > accumulator_t_right2;
@@ -40,10 +40,10 @@
accumulator_t_left1 acc1( left_tail_cache_size = c );
accumulator_t_right2 acc2( right_tail_cache_size = c );
accumulator_t_left2 acc3( left_tail_cache_size = c );
-
+
// a random number generator
boost::lagged_fibonacci607 rng;
-
+
for (std::size_t i = 0; i < n; ++i)
{
double sample = rng();
@@ -52,7 +52,7 @@
acc2(sample);
acc3(sample);
}
-
+
// check uniform distribution
BOOST_CHECK_CLOSE( non_coherent_tail_mean(acc0, quantile_probability = 0.95), 0.975, epsilon );
BOOST_CHECK_CLOSE( non_coherent_tail_mean(acc0, quantile_probability = 0.975), 0.9875, epsilon );
Modified: trunk/libs/accumulators/test/tail_quantile.cpp
==============================================================================
--- trunk/libs/accumulators/test/tail_quantile.cpp (original)
+++ trunk/libs/accumulators/test/tail_quantile.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -26,23 +26,23 @@
{
// tolerance in %
double epsilon = 1;
-
+
std::size_t n = 100000; // number of MC steps
std::size_t c = 10000; // cache size
-
+
typedef accumulator_set<double, stats<tag::tail_quantile<right> > > accumulator_t_right;
typedef accumulator_set<double, stats<tag::tail_quantile<left> > > accumulator_t_left;
-
+
accumulator_t_right acc0( right_tail_cache_size = c );
accumulator_t_right acc1( right_tail_cache_size = c );
accumulator_t_left acc2( left_tail_cache_size = c );
accumulator_t_left acc3( left_tail_cache_size = c );
-
+
// two random number generators
boost::lagged_fibonacci607 rng;
boost::normal_distribution<> mean_sigma(0,1);
boost::variate_generator<boost::lagged_fibonacci607&, boost::normal_distribution<> > normal(rng, mean_sigma);
-
+
for (std::size_t i = 0; i < n; ++i)
{
double sample1 = rng();
@@ -52,7 +52,7 @@
acc2(sample1);
acc3(sample2);
}
-
+
// check uniform distribution
BOOST_CHECK_CLOSE( quantile(acc0, quantile_probability = 0.95 ), 0.95, epsilon );
BOOST_CHECK_CLOSE( quantile(acc0, quantile_probability = 0.975), 0.975, epsilon );
@@ -62,13 +62,13 @@
BOOST_CHECK_CLOSE( quantile(acc2, quantile_probability = 0.025), 0.025, 2 );
BOOST_CHECK_CLOSE( quantile(acc2, quantile_probability = 0.01 ), 0.01, 3 );
BOOST_CHECK_CLOSE( quantile(acc2, quantile_probability = 0.001), 0.001, 20 );
-
+
// check standard normal distribution
BOOST_CHECK_CLOSE( quantile(acc1, quantile_probability = 0.975), 1.959963, epsilon );
BOOST_CHECK_CLOSE( quantile(acc1, quantile_probability = 0.999), 3.090232, epsilon );
BOOST_CHECK_CLOSE( quantile(acc3, quantile_probability = 0.025), -1.959963, epsilon );
BOOST_CHECK_CLOSE( quantile(acc3, quantile_probability = 0.001), -3.090232, epsilon );
-
+
}
///////////////////////////////////////////////////////////////////////////////
Modified: trunk/libs/accumulators/test/tail_variate_means.cpp
==============================================================================
--- trunk/libs/accumulators/test/tail_variate_means.cpp (original)
+++ trunk/libs/accumulators/test/tail_variate_means.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -26,20 +26,20 @@
void test_stat()
{
std::size_t c = 5; // cache size
-
+
typedef double variate_type;
typedef std::vector<variate_type> variate_set_type;
-
+
typedef accumulator_set<double, stats<tag::tail_variate_means<right, variate_set_type, tag::covariate1>(relative)> > accumulator_t1;
typedef accumulator_set<double, stats<tag::tail_variate_means<right, variate_set_type, tag::covariate1>(absolute)> > accumulator_t2;
typedef accumulator_set<double, stats<tag::tail_variate_means<left, variate_set_type, tag::covariate1>(relative)> > accumulator_t3;
typedef accumulator_set<double, stats<tag::tail_variate_means<left, variate_set_type, tag::covariate1>(absolute)> > accumulator_t4;
-
+
accumulator_t1 acc1( right_tail_cache_size = c );
accumulator_t2 acc2( right_tail_cache_size = c );
accumulator_t3 acc3( left_tail_cache_size = c );
accumulator_t4 acc4( left_tail_cache_size = c );
-
+
variate_set_type cov1, cov2, cov3, cov4, cov5;
double c1[] = { 10., 20., 30., 40. }; // 100
double c2[] = { 26., 4., 17., 3. }; // 50
@@ -50,32 +50,32 @@
cov2.assign(c2, c2 + sizeof(c2)/sizeof(variate_type));
cov3.assign(c3, c3 + sizeof(c3)/sizeof(variate_type));
cov4.assign(c4, c4 + sizeof(c4)/sizeof(variate_type));
- cov5.assign(c5, c5 + sizeof(c5)/sizeof(variate_type));
-
+ cov5.assign(c5, c5 + sizeof(c5)/sizeof(variate_type));
+
acc1(100., covariate1 = cov1);
acc1( 50., covariate1 = cov2);
acc1(200., covariate1 = cov3);
acc1( 80., covariate1 = cov4);
acc1( 20., covariate1 = cov5);
-
+
acc2(100., covariate1 = cov1);
acc2( 50., covariate1 = cov2);
acc2(200., covariate1 = cov3);
acc2( 80., covariate1 = cov4);
acc2( 20., covariate1 = cov5);
-
+
acc3(100., covariate1 = cov1);
acc3( 50., covariate1 = cov2);
acc3(200., covariate1 = cov3);
acc3( 80., covariate1 = cov4);
acc3( 20., covariate1 = cov5);
-
+
acc4(100., covariate1 = cov1);
acc4( 50., covariate1 = cov2);
acc4(200., covariate1 = cov3);
acc4( 80., covariate1 = cov4);
acc4( 20., covariate1 = cov5);
-
+
// check relative risk contributions
BOOST_CHECK_EQUAL( *(relative_tail_variate_means(acc1, quantile_probability = 0.7).begin() ), 14./75. ); // (10 + 46) / 300 = 14/75
BOOST_CHECK_EQUAL( *(relative_tail_variate_means(acc1, quantile_probability = 0.7).begin() + 1), 7./25. ); // (20 + 64) / 300 = 7/25
@@ -85,7 +85,7 @@
BOOST_CHECK_EQUAL( *(relative_tail_variate_means(acc3, quantile_probability = 0.3).begin() + 1), 3./35. ); // ( 4 + 2) / 70 = 3/35
BOOST_CHECK_EQUAL( *(relative_tail_variate_means(acc3, quantile_probability = 0.3).begin() + 2), 19./70. ); // (17 + 2) / 70 = 19/70
BOOST_CHECK_EQUAL( *(relative_tail_variate_means(acc3, quantile_probability = 0.3).begin() + 3), 17./70. ); // ( 3 + 14) / 70 = 17/70
-
+
// check absolute risk contributions
BOOST_CHECK_EQUAL( *(tail_variate_means(acc2, quantile_probability = 0.7).begin() ), 28 ); // (10 + 46) / 2 = 28
BOOST_CHECK_EQUAL( *(tail_variate_means(acc2, quantile_probability = 0.7).begin() + 1), 42 ); // (20 + 64) / 2 = 42
@@ -95,7 +95,7 @@
BOOST_CHECK_EQUAL( *(tail_variate_means(acc4, quantile_probability = 0.3).begin() + 1), 3 ); // ( 4 + 2) / 2 = 3
BOOST_CHECK_EQUAL( *(tail_variate_means(acc4, quantile_probability = 0.3).begin() + 2),9.5 ); // (17 + 2) / 2 = 9.5
BOOST_CHECK_EQUAL( *(tail_variate_means(acc4, quantile_probability = 0.3).begin() + 3),8.5 ); // ( 3 + 14) / 2 = 8.5
-
+
// check relative risk contributions
BOOST_CHECK_EQUAL( *(relative_tail_variate_means(acc1, quantile_probability = 0.9).begin() ), 23./100. ); // 46/200 = 23/100
BOOST_CHECK_EQUAL( *(relative_tail_variate_means(acc1, quantile_probability = 0.9).begin() + 1), 8./25. ); // 64/200 = 8/25
@@ -105,7 +105,7 @@
BOOST_CHECK_EQUAL( *(relative_tail_variate_means(acc3, quantile_probability = 0.1).begin() + 1), 1./10. ); // 2/ 20 = 1/10
BOOST_CHECK_EQUAL( *(relative_tail_variate_means(acc3, quantile_probability = 0.1).begin() + 2), 1./10. ); // 2/ 20 = 1/10
BOOST_CHECK_EQUAL( *(relative_tail_variate_means(acc3, quantile_probability = 0.1).begin() + 3), 7./10. ); // 14/ 20 = 7/10
-
+
// check absolute risk contributions
BOOST_CHECK_EQUAL( *(tail_variate_means(acc2, quantile_probability = 0.9).begin() ), 46 ); // 46
BOOST_CHECK_EQUAL( *(tail_variate_means(acc2, quantile_probability = 0.9).begin() + 1), 64 ); // 64
Modified: trunk/libs/accumulators/test/variance.cpp
==============================================================================
--- trunk/libs/accumulators/test/variance.cpp (original)
+++ trunk/libs/accumulators/test/variance.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -23,7 +23,7 @@
// >> mean(samples)
// ans = 3
// >> sum(samples .* samples) / length(samples)
- // ans = 11
+ // ans = 11
// >> sum(samples .* samples) / length(samples) - mean(samples)^2
// ans = 2
Modified: trunk/libs/accumulators/test/weighted_covariance.cpp
==============================================================================
--- trunk/libs/accumulators/test/weighted_covariance.cpp (original)
+++ trunk/libs/accumulators/test/weighted_covariance.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -24,12 +24,12 @@
std::vector<double> dummy;
dummy.push_back(0);
dummy.push_back(0);
-
+
accumulator_set<double, stats<tag::weighted_covariance<double, tag::covariate1> >, double > acc;
accumulator_set<std::vector<double>, stats<tag::weighted_covariance<double, tag::covariate1> >, double > acc2(sample = dummy);
accumulator_set<double, stats<tag::weighted_covariance<std::vector<double>, tag::covariate1> >, double > acc3(covariate1 = dummy);
accumulator_set<std::vector<double>, stats<tag::weighted_covariance<std::vector<double>, tag::covariate1> >, double > acc4(sample = dummy, covariate1 = dummy);
-
+
std::vector<double> a;
a.push_back(1.);
a.push_back(2.);
@@ -42,15 +42,15 @@
std::vector<double> d;
d.push_back(4.);
d.push_back(2.);
-
+
// double - double
{
acc(1., weight = 1.1, covariate1 = 2.);
acc(1., weight = 2.2, covariate1 = 4.);
acc(2., weight = 3.3, covariate1 = 3.);
- acc(6., weight = 4.4, covariate1 = 1.);
+ acc(6., weight = 4.4, covariate1 = 1.);
}
-
+
// vector - double
{
acc2(a, weight = 1.1, covariate1 = 1.);
@@ -58,7 +58,7 @@
acc2(c, weight = 3.3, covariate1 = 2.);
acc2(d, weight = 4.4, covariate1 = 6.);
}
-
+
// double - vector
{
acc3(1., weight = 1.1, covariate1 = a);
@@ -66,7 +66,7 @@
acc3(2., weight = 3.3, covariate1 = c);
acc3(6., weight = 4.4, covariate1 = d);
}
-
+
// vector - vector
{
acc4(a, weight = 1.1, covariate1 = b);
@@ -74,9 +74,9 @@
acc4(a, weight = 3.3, covariate1 = c);
acc4(d, weight = 4.4, covariate1 = b);
}
-
+
double epsilon = 1e-6;
-
+
BOOST_CHECK_CLOSE((weighted_covariance(acc)), -2.39, epsilon);
BOOST_CHECK_CLOSE((weighted_covariance(acc2))[0], 1.93, epsilon);
BOOST_CHECK_CLOSE((weighted_covariance(acc2))[1], -2.09, epsilon);
Modified: trunk/libs/accumulators/test/weighted_extended_p_square.cpp
==============================================================================
--- trunk/libs/accumulators/test/weighted_extended_p_square.cpp (original)
+++ trunk/libs/accumulators/test/weighted_extended_p_square.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -28,7 +28,7 @@
typedef accumulator_set<double, stats<tag::weighted_extended_p_square>, double> accumulator_t;
// problem with small results: epsilon is relative (in percent), not absolute
-
+
// tolerance in %
double epsilon = 1;
@@ -45,17 +45,17 @@
double p1[] = {/*0.001,*/ 0.01, 0.1, 0.5, 0.9, 0.99, 0.999};
probs_uniform.assign(p1, p1 + sizeof(p1) / sizeof(double));
-
+
double p2[] = {0.001, 0.025};
double p3[] = {0.975, 0.999};
probs_normal1.assign(p2, p2 + sizeof(p2) / sizeof(double));
probs_normal2.assign(p3, p3 + sizeof(p3) / sizeof(double));
-
+
double p4[] = {-3.090232, -1.959963};
double p5[] = {1.959963, 3.090232};
probs_normal_exact1.assign(p4, p4 + sizeof(p4) / sizeof(double));
probs_normal_exact2.assign(p5, p5 + sizeof(p5) / sizeof(double));
-
+
accumulator_t acc_uniform(extended_p_square_probabilities = probs_uniform);
accumulator_t acc_normal1(extended_p_square_probabilities = probs_normal1);
accumulator_t acc_normal2(extended_p_square_probabilities = probs_normal2);
@@ -63,19 +63,19 @@
for (std::size_t i = 0; i < 100000; ++i)
{
acc_uniform(rng(), weight = 1.);
-
+
double sample1 = normal1();
double sample2 = normal2();
acc_normal1(sample1, weight = std::exp(-mu1 * (sample1 - 0.5 * mu1)));
acc_normal2(sample2, weight = std::exp(-mu2 * (sample2 - 0.5 * mu2)));
}
-
- // check for uniform distribution
+
+ // check for uniform distribution
for (std::size_t i = 0; i < probs_uniform.size(); ++i)
{
BOOST_CHECK_CLOSE(weighted_extended_p_square(acc_uniform)[i], probs_uniform[i], epsilon);
}
-
+
// check for standard normal distribution
for (std::size_t i = 0; i < probs_normal1.size(); ++i)
{
Modified: trunk/libs/accumulators/test/weighted_kurtosis.cpp
==============================================================================
--- trunk/libs/accumulators/test/weighted_kurtosis.cpp (original)
+++ trunk/libs/accumulators/test/weighted_kurtosis.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -26,29 +26,29 @@
{
// tolerance in %
// double epsilon = 1;
-
+
accumulator_set<double, stats<tag::weighted_kurtosis>, double > acc1;
accumulator_set<int, stats<tag::weighted_kurtosis>, int > acc2;
-
+
// two random number generators
boost::lagged_fibonacci607 rng;
boost::normal_distribution<> mean_sigma(0,1);
boost::variate_generator<boost::lagged_fibonacci607&, boost::normal_distribution<> > normal(rng, mean_sigma);
-
+
for (std::size_t i=0; i<100000; ++i)
{
acc1(normal(), weight = rng());
}
-
+
// This check fails because epsilon is relative and not absolute
- // BOOST_CHECK_CLOSE( weighted_kurtosis(acc1), 0., epsilon );
-
+ // BOOST_CHECK_CLOSE( weighted_kurtosis(acc1), 0., epsilon );
+
acc2(2, weight = 4);
acc2(7, weight = 1);
acc2(4, weight = 3);
acc2(9, weight = 1);
acc2(3, weight = 2);
-
+
BOOST_CHECK_EQUAL( weighted_mean(acc2), 42./11. );
BOOST_CHECK_EQUAL( weighted_moment<2>(acc2), 212./11. );
BOOST_CHECK_EQUAL( weighted_moment<3>(acc2), 1350./11. );
Modified: trunk/libs/accumulators/test/weighted_mean.cpp
==============================================================================
--- trunk/libs/accumulators/test/weighted_mean.cpp (original)
+++ trunk/libs/accumulators/test/weighted_mean.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -32,7 +32,7 @@
, tag::mean_of_weights
, tag::weighted_mean_of_variates<int, tag::covariate1>
>
- , int
+ , int
> acc, test_acc(sample = 0);
acc(1, weight = 2, covariate1 = 3);
@@ -73,13 +73,13 @@
BOOST_CHECK_EQUAL(1u, count(acc2));
BOOST_CHECK_CLOSE(2., mean_of_weights(acc2), 1e-5);
BOOST_CHECK_CLOSE(3., (weighted_mean_of_variates<int, tag::covariate1>(acc2)), 1e-5);
-
+
acc2(0, weight = 4, covariate1 = 4);
BOOST_CHECK_CLOSE(1./3., weighted_mean(acc2), 1e-5);
BOOST_CHECK_EQUAL(2u, count(acc2));
BOOST_CHECK_CLOSE(3., mean_of_weights(acc2), 1e-5);
BOOST_CHECK_CLOSE(11./3., (weighted_mean_of_variates<int, tag::covariate1>(acc2)), 1e-5);
-
+
acc2(2, weight = 9, covariate1 = 8);
BOOST_CHECK_CLOSE(4./3., weighted_mean(acc2), 1e-5);
BOOST_CHECK_EQUAL(3u, count(acc2));
Modified: trunk/libs/accumulators/test/weighted_median.cpp
==============================================================================
--- trunk/libs/accumulators/test/weighted_median.cpp (original)
+++ trunk/libs/accumulators/test/weighted_median.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -22,7 +22,7 @@
{
// Median estimation of normal distribution N(1,1) using samples from a narrow normal distribution N(1,0.01)
// The weights equal to the likelihood ratio of the corresponding samples
-
+
// two random number generators
double mu = 1.;
double sigma_narrow = 0.01;
@@ -30,14 +30,14 @@
boost::lagged_fibonacci607 rng;
boost::normal_distribution<> mean_sigma_narrow(mu,sigma_narrow);
boost::variate_generator<boost::lagged_fibonacci607&, boost::normal_distribution<> > normal_narrow(rng, mean_sigma_narrow);
-
+
accumulator_set<double, stats<tag::weighted_median(with_p_square_quantile) >, double > acc;
- accumulator_set<double, stats<tag::weighted_median(with_density) >, double >
+ accumulator_set<double, stats<tag::weighted_median(with_density) >, double >
acc_dens( density_cache_size = 10000, density_num_bins = 1000 );
- accumulator_set<double, stats<tag::weighted_median(with_p_square_cumulative_distribution) >, double >
+ accumulator_set<double, stats<tag::weighted_median(with_p_square_cumulative_distribution) >, double >
acc_cdist( p_square_cumulative_distribution_num_cells = 100 );
-
-
+
+
for (std::size_t i=0; i<100000; ++i)
{
double sample = normal_narrow();
@@ -45,7 +45,7 @@
acc_dens(sample, weight = std::exp(0.5 * (sample - mu) * (sample - mu) * ( 1./sigma_narrow/sigma_narrow - 1./sigma/sigma )));
acc_cdist(sample, weight = std::exp(0.5 * (sample - mu) * (sample - mu) * ( 1./sigma_narrow/sigma_narrow - 1./sigma/sigma )));
}
-
+
BOOST_CHECK_CLOSE(1., weighted_median(acc), 1e-1);
BOOST_CHECK_CLOSE(1., weighted_median(acc_dens), 1e-1);
BOOST_CHECK_CLOSE(1., weighted_median(acc_cdist), 1e-1);
Modified: trunk/libs/accumulators/test/weighted_moment.cpp
==============================================================================
--- trunk/libs/accumulators/test/weighted_moment.cpp (original)
+++ trunk/libs/accumulators/test/weighted_moment.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -20,15 +20,15 @@
{
accumulator_set<double, stats<tag::weighted_moment<2> >, double> acc2;
accumulator_set<double, stats<tag::weighted_moment<7> >, double> acc7;
-
+
acc2(2.1, weight = 0.7);
acc2(2.7, weight = 1.4);
acc2(1.8, weight = 0.9);
-
+
acc7(2.1, weight = 0.7);
acc7(2.7, weight = 1.4);
acc7(1.8, weight = 0.9);
-
+
BOOST_CHECK_CLOSE(5.403, weighted_moment<2>(acc2), 1e-5);
BOOST_CHECK_CLOSE(548.54182, weighted_moment<7>(acc7), 1e-5);
}
Modified: trunk/libs/accumulators/test/weighted_p_square_cum_dist.cpp
==============================================================================
--- trunk/libs/accumulators/test/weighted_p_square_cum_dist.cpp (original)
+++ trunk/libs/accumulators/test/weighted_p_square_cum_dist.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -43,10 +43,10 @@
double epsilon = 4;
typedef accumulator_set<double, stats<tag::weighted_p_square_cumulative_distribution>, double > accumulator_t;
-
+
accumulator_t acc_upper(p_square_cumulative_distribution_num_cells = 100);
accumulator_t acc_lower(p_square_cumulative_distribution_num_cells = 100);
-
+
// two random number generators
double mu_upper = 1.0;
double mu_lower = -1.0;
@@ -55,38 +55,38 @@
boost::normal_distribution<> mean_sigma_lower(mu_lower,1);
boost::variate_generator<boost::lagged_fibonacci607&, boost::normal_distribution<> > normal_upper(rng, mean_sigma_upper);
boost::variate_generator<boost::lagged_fibonacci607&, boost::normal_distribution<> > normal_lower(rng, mean_sigma_lower);
-
+
for (std::size_t i=0; i<100000; ++i)
{
double sample = normal_upper();
acc_upper(sample, weight = std::exp(-mu_upper * (sample - 0.5 * mu_upper)));
}
-
+
for (std::size_t i=0; i<100000; ++i)
{
double sample = normal_lower();
acc_lower(sample, weight = std::exp(-mu_lower * (sample - 0.5 * mu_lower)));
}
-
+
typedef iterator_range<std::vector<std::pair<double, double> >::iterator > histogram_type;
histogram_type histogram_upper = weighted_p_square_cumulative_distribution(acc_upper);
histogram_type histogram_lower = weighted_p_square_cumulative_distribution(acc_lower);
-
- // Note that applaying importance sampling results in a region of the distribution
+
+ // Note that applaying importance sampling results in a region of the distribution
// to be estimated more accurately and another region to be estimated less accurately
// than without importance sampling, i.e., with unweighted samples
-
+
for (std::size_t i = 0; i < histogram_upper.size(); ++i)
- {
+ {
// problem with small results: epsilon is relative (in percent), not absolute!
-
+
// check upper region of distribution
- if ( histogram_upper[i].second > 0.1 )
+ if ( histogram_upper[i].second > 0.1 )
BOOST_CHECK_CLOSE( 0.5 * (1.0 + my_erf( histogram_upper[i].first / sqrt(2.0) )), histogram_upper[i].second, epsilon );
// check lower region of distribution
- if ( histogram_lower[i].second < -0.1 )
+ if ( histogram_lower[i].second < -0.1 )
BOOST_CHECK_CLOSE( 0.5 * (1.0 + my_erf( histogram_lower[i].first / sqrt(2.0) )), histogram_lower[i].second, epsilon );
- }
+ }
}
///////////////////////////////////////////////////////////////////////////////
Modified: trunk/libs/accumulators/test/weighted_p_square_quantile.cpp
==============================================================================
--- trunk/libs/accumulators/test/weighted_p_square_quantile.cpp (original)
+++ trunk/libs/accumulators/test/weighted_p_square_quantile.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -29,7 +29,7 @@
// tolerance in %
double epsilon = 1;
-
+
// some random number generators
double mu4 = -1.0;
double mu5 = -1.0;
@@ -44,7 +44,7 @@
boost::variate_generator<boost::lagged_fibonacci607&, boost::normal_distribution<> > normal5(rng, mean_sigma5);
boost::variate_generator<boost::lagged_fibonacci607&, boost::normal_distribution<> > normal6(rng, mean_sigma6);
boost::variate_generator<boost::lagged_fibonacci607&, boost::normal_distribution<> > normal7(rng, mean_sigma7);
-
+
accumulator_t acc0(quantile_probability = 0.001);
accumulator_t acc1(quantile_probability = 0.025);
accumulator_t acc2(quantile_probability = 0.975);
@@ -55,7 +55,7 @@
accumulator_t acc6(quantile_probability = 0.975);
accumulator_t acc7(quantile_probability = 0.999);
-
+
for (std::size_t i=0; i<100000; ++i)
{
double sample = rng();
@@ -63,7 +63,7 @@
acc1(sample, weight = 1.);
acc2(sample, weight = 1.);
acc3(sample, weight = 1.);
-
+
double sample4 = normal4();
double sample5 = normal5();
double sample6 = normal6();
@@ -78,7 +78,7 @@
BOOST_CHECK_CLOSE( weighted_p_square_quantile(acc1), 0.025, 5 );
BOOST_CHECK_CLOSE( weighted_p_square_quantile(acc2), 0.975, epsilon );
BOOST_CHECK_CLOSE( weighted_p_square_quantile(acc3), 0.999, epsilon );
-
+
// check for shifted standard normal distribution ("importance sampling")
BOOST_CHECK_CLOSE( weighted_p_square_quantile(acc4), -3.090232, epsilon );
BOOST_CHECK_CLOSE( weighted_p_square_quantile(acc5), -1.959963, epsilon );
Modified: trunk/libs/accumulators/test/weighted_pot_quantile.cpp
==============================================================================
--- trunk/libs/accumulators/test/weighted_pot_quantile.cpp (original)
+++ trunk/libs/accumulators/test/weighted_pot_quantile.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -28,11 +28,11 @@
double epsilon = 1.;
double mu1, mu2, l;
-
+
mu1 = 1.;
mu2 = -1.;
l = 0.5;
-
+
// two random number generators
boost::lagged_fibonacci607 rng;
boost::normal_distribution<> mean_sigma1(mu1,1);
@@ -41,7 +41,7 @@
boost::variate_generator<boost::lagged_fibonacci607&, boost::normal_distribution<> > normal1(rng, mean_sigma1);
boost::variate_generator<boost::lagged_fibonacci607&, boost::normal_distribution<> > normal2(rng, mean_sigma2);
boost::variate_generator<boost::lagged_fibonacci607&, boost::exponential_distribution<> > exponential(rng, lambda);
-
+
accumulator_set<double, stats<tag::weighted_pot_quantile<right>(with_threshold_value)>, double > acc1(
pot_threshold_value = 3.
);
@@ -56,7 +56,7 @@
left_tail_cache_size = 10000
, pot_threshold_probability = 0.01
);
-
+
accumulator_set<double, stats<tag::weighted_pot_quantile<right>(with_threshold_value)>, double > acc5(
pot_threshold_value = 5.
);
@@ -64,7 +64,7 @@
right_tail_cache_size = 10000
, pot_threshold_probability = 0.995
);
-
+
for (std::size_t i = 0; i < 100000; ++i)
{
double sample1 = normal1();
@@ -74,21 +74,21 @@
acc3(sample2, weight = std::exp(-mu2 * (sample2 - 0.5 * mu2)));
acc4(sample2, weight = std::exp(-mu2 * (sample2 - 0.5 * mu2)));
}
-
+
for (std::size_t i = 0; i < 100000; ++i)
{
double sample = exponential();
acc5(sample, weight = 1./l * std::exp(-sample * (1. - l)));
acc6(sample, weight = 1./l * std::exp(-sample * (1. - l)));
}
-
+
BOOST_CHECK_CLOSE( quantile(acc1, quantile_probability = 0.999), 3.090232, epsilon );
- BOOST_CHECK_CLOSE( quantile(acc2, quantile_probability = 0.999), 3.090232, epsilon );
+ BOOST_CHECK_CLOSE( quantile(acc2, quantile_probability = 0.999), 3.090232, epsilon );
BOOST_CHECK_CLOSE( quantile(acc3, quantile_probability = 0.001), -3.090232, epsilon );
- BOOST_CHECK_CLOSE( quantile(acc4, quantile_probability = 0.001), -3.090232, epsilon );
-
+ BOOST_CHECK_CLOSE( quantile(acc4, quantile_probability = 0.001), -3.090232, epsilon );
+
BOOST_CHECK_CLOSE( quantile(acc5, quantile_probability = 0.999), 6.908, epsilon );
- BOOST_CHECK_CLOSE( quantile(acc6, quantile_probability = 0.999), 6.908, epsilon );
+ BOOST_CHECK_CLOSE( quantile(acc6, quantile_probability = 0.999), 6.908, epsilon );
}
///////////////////////////////////////////////////////////////////////////////
Modified: trunk/libs/accumulators/test/weighted_skewness.cpp
==============================================================================
--- trunk/libs/accumulators/test/weighted_skewness.cpp (original)
+++ trunk/libs/accumulators/test/weighted_skewness.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -26,29 +26,29 @@
{
// tolerance in %
// double epsilon = 1;
-
+
accumulator_set<double, stats<tag::weighted_skewness>, double > acc1;
accumulator_set<int, stats<tag::weighted_skewness>, int > acc2;
-
+
// two random number generators
boost::lagged_fibonacci607 rng;
boost::normal_distribution<> mean_sigma(0,1);
boost::variate_generator<boost::lagged_fibonacci607&, boost::normal_distribution<> > normal(rng, mean_sigma);
-
+
for (std::size_t i=0; i<100000; ++i)
{
acc1(normal(), weight = rng());
}
-
+
// This check fails because epsilon is relative and not absolute
- // BOOST_CHECK_CLOSE( weighted_skewness(acc1), 0., epsilon );
-
+ // BOOST_CHECK_CLOSE( weighted_skewness(acc1), 0., epsilon );
+
acc2(2, weight = 4);
acc2(7, weight = 1);
acc2(4, weight = 3);
acc2(9, weight = 1);
acc2(3, weight = 2);
-
+
BOOST_CHECK_EQUAL( weighted_mean(acc2), 42./11. );
BOOST_CHECK_EQUAL( weighted_moment<2>(acc2), 212./11. );
BOOST_CHECK_EQUAL( weighted_moment<3>(acc2), 1350./11. );
Modified: trunk/libs/accumulators/test/weighted_tail_mean.cpp
==============================================================================
--- trunk/libs/accumulators/test/weighted_tail_mean.cpp (original)
+++ trunk/libs/accumulators/test/weighted_tail_mean.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -28,30 +28,30 @@
{
// tolerance in %
double epsilon = 1;
-
+
std::size_t n = 100000; // number of MC steps
std::size_t c = 25000; // cache size
-
+
accumulator_set<double, stats<tag::non_coherent_weighted_tail_mean<right> >, double >
acc0( right_tail_cache_size = c );
accumulator_set<double, stats<tag::non_coherent_weighted_tail_mean<left> >, double >
acc1( left_tail_cache_size = c );
-
+
// random number generators
boost::lagged_fibonacci607 rng;
-
+
for (std::size_t i = 0; i < n; ++i)
{
double smpl = std::sqrt(rng());
acc0(smpl, weight = 1./smpl);
}
-
+
for (std::size_t i = 0; i < n; ++i)
{
double smpl = rng();
acc1(smpl*smpl, weight = smpl);
}
-
+
// check uniform distribution
BOOST_CHECK_CLOSE( non_coherent_weighted_tail_mean(acc0, quantile_probability = 0.95), 0.975, epsilon );
BOOST_CHECK_CLOSE( non_coherent_weighted_tail_mean(acc0, quantile_probability = 0.975), 0.9875, epsilon );
Modified: trunk/libs/accumulators/test/weighted_tail_quantile.cpp
==============================================================================
--- trunk/libs/accumulators/test/weighted_tail_quantile.cpp (original)
+++ trunk/libs/accumulators/test/weighted_tail_quantile.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -27,10 +27,10 @@
{
// tolerance in %
double epsilon = 1;
-
+
std::size_t n = 100000; // number of MC steps
std::size_t c = 20000; // cache size
-
+
double mu1 = 1.0;
double mu2 = -1.0;
boost::lagged_fibonacci607 rng;
@@ -38,13 +38,13 @@
boost::normal_distribution<> mean_sigma2(mu2,1);
boost::variate_generator<boost::lagged_fibonacci607&, boost::normal_distribution<> > normal1(rng, mean_sigma1);
boost::variate_generator<boost::lagged_fibonacci607&, boost::normal_distribution<> > normal2(rng, mean_sigma2);
-
+
accumulator_set<double, stats<tag::weighted_tail_quantile<right> >, double>
acc1(right_tail_cache_size = c);
accumulator_set<double, stats<tag::weighted_tail_quantile<left> >, double>
- acc2(left_tail_cache_size = c);
-
+ acc2(left_tail_cache_size = c);
+
for (std::size_t i = 0; i < n; ++i)
{
double sample1 = normal1();
@@ -52,13 +52,13 @@
acc1(sample1, weight = std::exp(-mu1 * (sample1 - 0.5 * mu1)));
acc2(sample2, weight = std::exp(-mu2 * (sample2 - 0.5 * mu2)));
}
-
+
// check standard normal distribution
BOOST_CHECK_CLOSE( quantile(acc1, quantile_probability = 0.975), 1.959963, epsilon );
BOOST_CHECK_CLOSE( quantile(acc1, quantile_probability = 0.999), 3.090232, epsilon );
BOOST_CHECK_CLOSE( quantile(acc2, quantile_probability = 0.025), -1.959963, epsilon );
BOOST_CHECK_CLOSE( quantile(acc2, quantile_probability = 0.001), -3.090232, epsilon );
-
+
}
///////////////////////////////////////////////////////////////////////////////
Modified: trunk/libs/accumulators/test/weighted_tail_variate_means.cpp
==============================================================================
--- trunk/libs/accumulators/test/weighted_tail_variate_means.cpp (original)
+++ trunk/libs/accumulators/test/weighted_tail_variate_means.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -27,10 +27,10 @@
void test_stat()
{
std::size_t c = 5; // cache size
-
+
typedef double variate_type;
typedef std::vector<variate_type> variate_set_type;
-
+
accumulator_set<double, stats<tag::weighted_tail_variate_means<right, variate_set_type, tag::covariate1>(relative)>, double >
acc1( right_tail_cache_size = c );
accumulator_set<double, stats<tag::weighted_tail_variate_means<right, variate_set_type, tag::covariate1>(absolute)>, double >
@@ -39,7 +39,7 @@
acc3( left_tail_cache_size = c );
accumulator_set<double, stats<tag::weighted_tail_variate_means<left, variate_set_type, tag::covariate1>(absolute)>, double >
acc4( left_tail_cache_size = c );
-
+
variate_set_type cov1, cov2, cov3, cov4, cov5;
double c1[] = { 10., 20., 30., 40. }; // 100
double c2[] = { 26., 4., 17., 3. }; // 50
@@ -50,32 +50,32 @@
cov2.assign(c2, c2 + sizeof(c2)/sizeof(variate_type));
cov3.assign(c3, c3 + sizeof(c3)/sizeof(variate_type));
cov4.assign(c4, c4 + sizeof(c4)/sizeof(variate_type));
- cov5.assign(c5, c5 + sizeof(c5)/sizeof(variate_type));
-
+ cov5.assign(c5, c5 + sizeof(c5)/sizeof(variate_type));
+
acc1(100., weight = 0.8, covariate1 = cov1);
acc1( 50., weight = 0.9, covariate1 = cov2);
acc1(200., weight = 1.0, covariate1 = cov3);
acc1( 80., weight = 1.1, covariate1 = cov4);
acc1( 20., weight = 1.2, covariate1 = cov5);
-
+
acc2(100., weight = 0.8, covariate1 = cov1);
acc2( 50., weight = 0.9, covariate1 = cov2);
acc2(200., weight = 1.0, covariate1 = cov3);
acc2( 80., weight = 1.1, covariate1 = cov4);
acc2( 20., weight = 1.2, covariate1 = cov5);
-
+
acc3(100., weight = 0.8, covariate1 = cov1);
acc3( 50., weight = 0.9, covariate1 = cov2);
acc3(200., weight = 1.0, covariate1 = cov3);
acc3( 80., weight = 1.1, covariate1 = cov4);
acc3( 20., weight = 1.2, covariate1 = cov5);
-
+
acc4(100., weight = 0.8, covariate1 = cov1);
acc4( 50., weight = 0.9, covariate1 = cov2);
acc4(200., weight = 1.0, covariate1 = cov3);
acc4( 80., weight = 1.1, covariate1 = cov4);
acc4( 20., weight = 1.2, covariate1 = cov5);
-
+
// check relative risk contributions
BOOST_CHECK_EQUAL( *(relative_weighted_tail_variate_means(acc1, quantile_probability = 0.7).begin() ), (0.8*10 + 1.0*46)/(0.8*100 + 1.0*200) );
BOOST_CHECK_EQUAL( *(relative_weighted_tail_variate_means(acc1, quantile_probability = 0.7).begin() + 1), (0.8*20 + 1.0*64)/(0.8*100 + 1.0*200) );
@@ -85,7 +85,7 @@
BOOST_CHECK_EQUAL( *(relative_weighted_tail_variate_means(acc3, quantile_probability = 0.3).begin() + 1), (0.9*4 + 1.2*2)/(0.9*50 + 1.2*20) );
BOOST_CHECK_EQUAL( *(relative_weighted_tail_variate_means(acc3, quantile_probability = 0.3).begin() + 2), (0.9*17 + 1.2*2)/(0.9*50 + 1.2*20) );
BOOST_CHECK_EQUAL( *(relative_weighted_tail_variate_means(acc3, quantile_probability = 0.3).begin() + 3), (0.9*3 + 1.2*14)/(0.9*50 + 1.2*20) );
-
+
// check absolute risk contributions
BOOST_CHECK_EQUAL( *(weighted_tail_variate_means(acc2, quantile_probability = 0.7).begin() ), (0.8*10 + 1.0*46)/1.8 );
BOOST_CHECK_EQUAL( *(weighted_tail_variate_means(acc2, quantile_probability = 0.7).begin() + 1), (0.8*20 + 1.0*64)/1.8 );
@@ -95,7 +95,7 @@
BOOST_CHECK_EQUAL( *(weighted_tail_variate_means(acc4, quantile_probability = 0.3).begin() + 1), (0.9*4 + 1.2*2)/2.1 );
BOOST_CHECK_EQUAL( *(weighted_tail_variate_means(acc4, quantile_probability = 0.3).begin() + 2), (0.9*17 + 1.2*2)/2.1 );
BOOST_CHECK_EQUAL( *(weighted_tail_variate_means(acc4, quantile_probability = 0.3).begin() + 3), (0.9*3 + 1.2*14)/2.1 );
-
+
// check relative risk contributions
BOOST_CHECK_EQUAL( *(relative_weighted_tail_variate_means(acc1, quantile_probability = 0.9).begin() ), 1.0*46/(1.0*200) );
BOOST_CHECK_EQUAL( *(relative_weighted_tail_variate_means(acc1, quantile_probability = 0.9).begin() + 1), 1.0*64/(1.0*200) );
@@ -105,7 +105,7 @@
BOOST_CHECK_EQUAL( *(relative_weighted_tail_variate_means(acc3, quantile_probability = 0.1).begin() + 1), 1.2*2/(1.2*20) );
BOOST_CHECK_EQUAL( *(relative_weighted_tail_variate_means(acc3, quantile_probability = 0.1).begin() + 2), 1.2*2/(1.2*20) );
BOOST_CHECK_EQUAL( *(relative_weighted_tail_variate_means(acc3, quantile_probability = 0.1).begin() + 3), 1.2*14/(1.2*20) );
-
+
// check absolute risk contributions
BOOST_CHECK_EQUAL( *(weighted_tail_variate_means(acc2, quantile_probability = 0.9).begin() ), 1.0*46/1.0 );
BOOST_CHECK_EQUAL( *(weighted_tail_variate_means(acc2, quantile_probability = 0.9).begin() + 1), 1.0*64/1.0 );
Modified: trunk/libs/accumulators/test/weighted_variance.cpp
==============================================================================
--- trunk/libs/accumulators/test/weighted_variance.cpp (original)
+++ trunk/libs/accumulators/test/weighted_variance.cpp 2008-01-08 13:43:43 EST (Tue, 08 Jan 2008)
@@ -46,24 +46,24 @@
BOOST_CHECK_EQUAL(5u, count(acc2));
BOOST_CHECK_CLOSE(2.9090909, weighted_mean(acc2), 1e-5);
BOOST_CHECK_CLOSE(1.7190083, weighted_variance(acc2), 1e-5);
-
+
// check lazy and immediate variance with random numbers
-
+
// two random number generators
boost::lagged_fibonacci607 rng;
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>, double > acc_lazy;
accumulator_set<double, stats<tag::weighted_variance(immediate)>, double > acc_immediate;
-
+
for (std::size_t i=0; i<10000; ++i)
{
double value = normal();
acc_lazy(value, weight = rng());
acc_immediate(value, weight = rng());
}
-
+
BOOST_CHECK_CLOSE(1., weighted_variance(acc_lazy), 1.);
BOOST_CHECK_CLOSE(1., weighted_variance(acc_immediate), 1.);
}
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