Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r72886 - sandbox/acc_ecdf/libs/accumulators/ecdf/test
From: erwann.rogard_at_[hidden]
Date: 2011-07-04 12:22:15


Author: e_r
Date: 2011-07-04 12:22:14 EDT (Mon, 04 Jul 2011)
New Revision: 72886
URL: http://svn.boost.org/trac/boost/changeset/72886

Log:
upd acc_ecdf
Added:
   sandbox/acc_ecdf/libs/accumulators/ecdf/test/Jamfile.v2 (contents, props changed)
   sandbox/acc_ecdf/libs/accumulators/ecdf/test/cdf.cpp (contents, props changed)
   sandbox/acc_ecdf/libs/accumulators/ecdf/test/cdf.h (contents, props changed)
   sandbox/acc_ecdf/libs/accumulators/ecdf/test/count.cpp (contents, props changed)
   sandbox/acc_ecdf/libs/accumulators/ecdf/test/count.h (contents, props changed)
   sandbox/acc_ecdf/libs/accumulators/ecdf/test/cumulative_count.cpp (contents, props changed)
   sandbox/acc_ecdf/libs/accumulators/ecdf/test/cumulative_count.h (contents, props changed)
   sandbox/acc_ecdf/libs/accumulators/ecdf/test/kolmogorov_smirnov_statistic.cpp (contents, props changed)
   sandbox/acc_ecdf/libs/accumulators/ecdf/test/kolmogorov_smirnov_statistic.h (contents, props changed)
   sandbox/acc_ecdf/libs/accumulators/ecdf/test/ks_gen.cpp (contents, props changed)
   sandbox/acc_ecdf/libs/accumulators/ecdf/test/ks_gen.h (contents, props changed)
   sandbox/acc_ecdf/libs/accumulators/ecdf/test/pdf.cpp (contents, props changed)
   sandbox/acc_ecdf/libs/accumulators/ecdf/test/pdf.h (contents, props changed)
   sandbox/acc_ecdf/libs/accumulators/ecdf/test/unit_test.cpp (contents, props changed)
Removed:
   sandbox/acc_ecdf/libs/accumulators/ecdf/test/ks_sim.cpp
   sandbox/acc_ecdf/libs/accumulators/ecdf/test/ks_sim.h

Added: sandbox/acc_ecdf/libs/accumulators/ecdf/test/Jamfile.v2
==============================================================================
--- (empty file)
+++ sandbox/acc_ecdf/libs/accumulators/ecdf/test/Jamfile.v2 2011-07-04 12:22:14 EDT (Mon, 04 Jul 2011)
@@ -0,0 +1,10 @@
+rule ecdf-test ( name )
+{
+ return [
+ run $(name).cpp /boost/test//boost_unit_test_framework/<link>static ]
+ ;
+}
+
+test-suite ecdf :
+ [ ecdf-test unit_test ]
+;

Added: sandbox/acc_ecdf/libs/accumulators/ecdf/test/cdf.cpp
==============================================================================
--- (empty file)
+++ sandbox/acc_ecdf/libs/accumulators/ecdf/test/cdf.cpp 2011-07-04 12:22:14 EDT (Mon, 04 Jul 2011)
@@ -0,0 +1,62 @@
+///////////////////////////////////////////////////////////////////////////////
+// accumulator_ecdf //
+// //
+// Copyright (C) 2005 Eric Niebler //
+// Copyright (C) 2011 Erwann Rogard //
+// Software License, Version 1.0. (See accompanying file //
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
+///////////////////////////////////////////////////////////////////////////////
+#include <cstddef>
+#include <boost/accumulators/accumulators.hpp>
+#include <boost/accumulators/statistics/stats.hpp>
+#include <boost/accumulators/statistics/ecdf/aux_/check.hpp>
+#include <boost/accumulators/statistics/ecdf/cdf.hpp>
+#include <libs/accumulators/ecdf/test/cdf.h>
+
+void test_ecdf_cdf()
+{
+ using namespace boost;
+ using namespace accumulators;
+
+//[test_ecdf_cdf
+ typedef double float_;
+ accumulator_set<
+ int,
+ stats<ecdf::tag::cdf<float_> >
+ > acc;
+
+ // Layout is chosen for its clarify, but there is no need to assume a
+ // particular ordering
+ acc( 1 );
+ acc( 2 ); acc( 2 );
+ acc( 3 ); acc( 3 ); acc( 3 );
+
+ typedef numeric::bounds<float_> bounds_;
+ typedef numeric::converter<std::size_t, float_> converter_;
+
+ float_ n = converter_::convert( count( acc ) );
+ float_ result, benchmark, eps = bounds_::smallest();
+
+ result = ecdf::cdf<float_>( acc , 0 );
+ benchmark = converter_::convert( 0 ) / n;
+ BOOST_ACCUMULATORS_ECDF_CHECK( fabs( result - benchmark ) < eps );
+
+ result = ecdf::cdf<float_>( acc , 1 );
+ benchmark = converter_::convert( 1 ) / n;
+ BOOST_ACCUMULATORS_ECDF_CHECK( fabs( result - benchmark ) < eps );
+
+ result = ecdf::cdf<float_>( acc , 2 );
+ benchmark = converter_::convert( 1 + 2 ) / n;
+ BOOST_ACCUMULATORS_ECDF_CHECK( fabs( result - benchmark ) < eps );
+
+ result = ecdf::cdf<float_>( acc , 3 );
+ benchmark = 1.0;
+ BOOST_ACCUMULATORS_ECDF_CHECK( fabs( result - benchmark ) < eps );
+
+ result = ecdf::cdf<float_>( acc , 4 );
+ benchmark = 1.0;
+ BOOST_ACCUMULATORS_ECDF_CHECK( fabs( result - benchmark ) < eps );
+
+//]
+
+}
\ No newline at end of file

Added: sandbox/acc_ecdf/libs/accumulators/ecdf/test/cdf.h
==============================================================================
--- (empty file)
+++ sandbox/acc_ecdf/libs/accumulators/ecdf/test/cdf.h 2011-07-04 12:22:14 EDT (Mon, 04 Jul 2011)
@@ -0,0 +1,11 @@
+///////////////////////////////////////////////////////////////////////////////
+// accumulator_ecdf //
+// //
+// Copyright (C) 2005 Eric Niebler //
+// Copyright (C) 2011 Erwann Rogard //
+// Software License, Version 1.0. (See accompanying file //
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
+///////////////////////////////////////////////////////////////////////////////
+
+
+void test_ecdf_cdf();

Added: sandbox/acc_ecdf/libs/accumulators/ecdf/test/count.cpp
==============================================================================
--- (empty file)
+++ sandbox/acc_ecdf/libs/accumulators/ecdf/test/count.cpp 2011-07-04 12:22:14 EDT (Mon, 04 Jul 2011)
@@ -0,0 +1,41 @@
+///////////////////////////////////////////////////////////////////////////////
+// accumulator_ecdf //
+// //
+// Copyright (C) 2005 Eric Niebler //
+// Copyright (C) 2011 Erwann Rogard //
+// Software License, Version 1.0. (See accompanying file //
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
+///////////////////////////////////////////////////////////////////////////////
+#include <cstddef>
+#include <boost/accumulators/accumulators.hpp>
+#include <boost/accumulators/statistics/stats.hpp>
+#include <boost/accumulators/statistics/ecdf/aux_/check.hpp>
+#include <boost/accumulators/statistics/ecdf/count.hpp>
+#include <libs/accumulators/ecdf/test/count.h>
+
+void test_ecdf_count()
+{
+ using namespace boost;
+ using namespace accumulators;
+
+//[test_ecdf_count
+ accumulator_set<
+ int,
+ stats<ecdf::tag::count>
+ > acc;
+
+ // Layout is chosen for its clarify, but there is no need to assume a
+ // particular ordering
+ acc( 1 );
+ acc( 2 ); acc( 2 );
+ acc( 3 ); acc( 3 ); acc( 3 );
+
+ BOOST_ACCUMULATORS_ECDF_CHECK( ecdf::count( acc , 0 ) == 0 );
+ BOOST_ACCUMULATORS_ECDF_CHECK( ecdf::count( acc , 1 ) == 1 );
+ BOOST_ACCUMULATORS_ECDF_CHECK( ecdf::count( acc , 2 ) == 2 );
+ BOOST_ACCUMULATORS_ECDF_CHECK( ecdf::count( acc , 3 ) == 3 );
+ BOOST_ACCUMULATORS_ECDF_CHECK( ecdf::count( acc , 4 ) == 0 );
+//]
+
+}
+

Added: sandbox/acc_ecdf/libs/accumulators/ecdf/test/count.h
==============================================================================
--- (empty file)
+++ sandbox/acc_ecdf/libs/accumulators/ecdf/test/count.h 2011-07-04 12:22:14 EDT (Mon, 04 Jul 2011)
@@ -0,0 +1,11 @@
+///////////////////////////////////////////////////////////////////////////////
+// accumulator_ecdf //
+// //
+// Copyright (C) 2005 Eric Niebler //
+// Copyright (C) 2011 Erwann Rogard //
+// Software License, Version 1.0. (See accompanying file //
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
+///////////////////////////////////////////////////////////////////////////////
+
+
+void test_ecdf_count();

Added: sandbox/acc_ecdf/libs/accumulators/ecdf/test/cumulative_count.cpp
==============================================================================
--- (empty file)
+++ sandbox/acc_ecdf/libs/accumulators/ecdf/test/cumulative_count.cpp 2011-07-04 12:22:14 EDT (Mon, 04 Jul 2011)
@@ -0,0 +1,40 @@
+///////////////////////////////////////////////////////////////////////////////
+// accumulator_ecdf //
+// //
+// Copyright (C) 2005 Eric Niebler //
+// Copyright (C) 2011 Erwann Rogard //
+// Software License, Version 1.0. (See accompanying file //
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
+///////////////////////////////////////////////////////////////////////////////
+#include <cstddef>
+#include <boost/accumulators/accumulators.hpp>
+#include <boost/accumulators/statistics/stats.hpp>
+#include <boost/accumulators/statistics/ecdf/aux_/check.hpp>
+#include <boost/accumulators/statistics/ecdf/cumulative_count.hpp>
+#include <libs/accumulators/ecdf/test/cumulative_count.h>
+
+void test_ecdf_cumulative_count()
+{
+ using namespace boost;
+ using namespace accumulators;
+
+//[test_ecdf_cumulative_count
+ accumulator_set<
+ int,
+ stats<ecdf::tag::cumulative_count>
+ > acc;
+
+ // Layout is chosen for its clarify, but there is no need to assume a
+ // particular ordering
+ acc( 1 );
+ acc( 2 ); acc( 2 );
+ acc( 3 ); acc( 3 ); acc( 3 );
+
+ BOOST_ACCUMULATORS_ECDF_CHECK( ecdf::cumulative_count( acc , 0 ) == 0 );
+ BOOST_ACCUMULATORS_ECDF_CHECK( ecdf::cumulative_count( acc , 1 ) == 1 );
+ BOOST_ACCUMULATORS_ECDF_CHECK( ecdf::cumulative_count( acc , 2 ) == 3 );
+ BOOST_ACCUMULATORS_ECDF_CHECK( ecdf::cumulative_count( acc , 3 ) == 6 );
+ BOOST_ACCUMULATORS_ECDF_CHECK( ecdf::cumulative_count( acc , 4 ) == 6 );
+//]
+
+}
\ No newline at end of file

Added: sandbox/acc_ecdf/libs/accumulators/ecdf/test/cumulative_count.h
==============================================================================
--- (empty file)
+++ sandbox/acc_ecdf/libs/accumulators/ecdf/test/cumulative_count.h 2011-07-04 12:22:14 EDT (Mon, 04 Jul 2011)
@@ -0,0 +1,11 @@
+///////////////////////////////////////////////////////////////////////////////
+// accumulator_ecdf //
+// //
+// Copyright (C) 2005 Eric Niebler //
+// Copyright (C) 2011 Erwann Rogard //
+// Software License, Version 1.0. (See accompanying file //
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
+///////////////////////////////////////////////////////////////////////////////
+
+
+void test_ecdf_cumulative_count();

Added: sandbox/acc_ecdf/libs/accumulators/ecdf/test/kolmogorov_smirnov_statistic.cpp
==============================================================================
--- (empty file)
+++ sandbox/acc_ecdf/libs/accumulators/ecdf/test/kolmogorov_smirnov_statistic.cpp 2011-07-04 12:22:14 EDT (Mon, 04 Jul 2011)
@@ -0,0 +1,58 @@
+///////////////////////////////////////////////////////////////////////////////
+// accumulator_ecdf //
+// //
+// Copyright (C) 2005 Eric Niebler //
+// Copyright (C) 2011 Erwann Rogard //
+// Software License, Version 1.0. (See accompanying file //
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
+///////////////////////////////////////////////////////////////////////////////
+#include <cstddef>
+#include <boost/accumulators/accumulators.hpp>
+#include <boost/accumulators/statistics/stats.hpp>
+#include <boost/accumulators/statistics/ecdf/aux_/check.hpp>
+#include <boost/accumulators/statistics/ecdf/cdf.hpp>
+#include <boost/accumulators/statistics/ecdf/kolmogorov_smirnov_statistic.hpp>
+#include <boost/math/distributions/poisson.hpp>
+#include <libs/accumulators/ecdf/test/kolmogorov_smirnov_statistic.h>
+
+void test_ecdf_kolmogorov_smirnov_statistic()
+{
+ using namespace boost;
+ using namespace accumulators;
+
+//[test_ecdf_kolmogorov_smirnov_statistic
+ typedef double float_;
+ boost::math::poisson_distribution<> dist( 1.0 );
+ accumulator_set<
+ int,
+ stats<
+ ecdf::tag::cdf<float_>,
+ ecdf::tag::kolmogorov_smirnov_statistic
+ >
+ > acc;
+
+ typedef numeric::bounds<float_> bounds_;
+ typedef numeric::converter<std::size_t, float_> converter_;
+
+ // Layout is chosen for its clarify, but there is no need to assume a
+ // particular ordering
+ acc( 1 );
+ acc( 2 ); acc( 2 );
+ acc( 3 ); acc( 3 ); acc( 3 );
+
+ float_
+ benchmark = bounds_::smallest(),
+ eps = bounds_::smallest(),
+ max_diff;
+
+ for(std::size_t i = 1; i < 4; i++ )
+ {
+ max_diff = fabs( math::cdf( dist, i ) - ecdf::cdf<float_>( acc, i ) );
+ benchmark = ( benchmark < max_diff ) ? max_diff : benchmark ;
+ }
+ float_ result = ecdf::kolmogorov_smirnov_statistic<float_>( acc, dist );
+ BOOST_ACCUMULATORS_ECDF_CHECK( fabs( result - benchmark ) < eps );
+
+//]
+
+}
\ No newline at end of file

Added: sandbox/acc_ecdf/libs/accumulators/ecdf/test/kolmogorov_smirnov_statistic.h
==============================================================================
--- (empty file)
+++ sandbox/acc_ecdf/libs/accumulators/ecdf/test/kolmogorov_smirnov_statistic.h 2011-07-04 12:22:14 EDT (Mon, 04 Jul 2011)
@@ -0,0 +1,11 @@
+///////////////////////////////////////////////////////////////////////////////
+// accumulator_ecdf //
+// //
+// Copyright (C) 2005 Eric Niebler //
+// Copyright (C) 2011 Erwann Rogard //
+// Software License, Version 1.0. (See accompanying file //
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
+///////////////////////////////////////////////////////////////////////////////
+
+
+void test_ecdf_kolmogorov_smirnov_statistic();

Added: sandbox/acc_ecdf/libs/accumulators/ecdf/test/ks_gen.cpp
==============================================================================
--- (empty file)
+++ sandbox/acc_ecdf/libs/accumulators/ecdf/test/ks_gen.cpp 2011-07-04 12:22:14 EDT (Mon, 04 Jul 2011)
@@ -0,0 +1,137 @@
+///////////////////////////////////////////////////////////////////////////////
+// kolmogorov_smirnov_statistic.cpp //
+// //
+// Copyright (C) 2005 Eric Niebler //
+// Copyright (C) 2011 Erwann Rogard //
+// Software License, Version 1.0. (See accompanying file //
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
+///////////////////////////////////////////////////////////////////////////////
+#include <vector>
+#include <iterator>
+#include <string>
+#include <boost/accumulators/accumulators.hpp>
+#include <boost/accumulators/statistics/ecdf/aux_/incremental_simulator.hpp>
+#include <boost/accumulators/statistics/ecdf/aux_/kolmogorov_smirnov_generator.hpp>
+#include <boost/accumulators/statistics/stats.hpp>
+#include <boost/format.hpp>
+#include <boost/foreach.hpp>
+#include <boost/mpl/int.hpp>
+#include <boost/math/distributions/normal.hpp>
+#include <boost/math/distributions/poisson.hpp>
+#include <boost/range/algorithm/transform.hpp>
+#include <boost/random/normal_distribution.hpp>
+#include <boost/random/mersenne_twister.hpp>
+#include <boost/random/poisson_distribution.hpp>
+#include <boost/random/variate_generator.hpp>
+#include <boost/typeof/typeof.hpp>
+#include <libs/accumulators/ecdf/test/ks_gen.h>
+
+void test_ks_gen(
+ std::ostream& os,
+ double mean,
+ long n,
+ long factor,
+ long size
+)
+{
+
+ using namespace boost::accumulators;
+ const std::string str = "sample size vs kolmogorov smirnov statisic:";
+ // A series of Kolmogorov-Smirnov statistics, computed over an iid
+ // sample of increasing size (n). The reference distribution is that of
+ // the random generator, so the series is expected to converge to zero.
+ // Warning : numeric error may dominate for large n.
+
+ {
+//[test_ks_gen1
+ typedef boost::math::poisson_distribution<> dist_;
+ typedef dist_::value_type val_;
+ typedef boost::poisson_distribution<> random_;
+ typedef boost::mt19937 urng_;
+ typedef boost::variate_generator<urng_&,random_> vg_;
+ dist_ dist( mean );
+ urng_ urng;
+ vg_ vg( urng, random_( mean ) );
+
+ os << "poisson(" << mean << ')' << std::endl;
+
+ // If vg draws from dist, convergence to zero is expected
+ std::generate_n(
+ std::ostream_iterator<boost::format>( os, "\n" ),
+ size,
+ ecdf::aux_::make_kolmogorov_smirnov_generator( vg, dist )
+ );
+
+ os << std::endl;
+
+/*
+ouputs:
+poisson(1)
+(1, 0.0803014)
+(2, 0.132121)
+(4, 0.117879)
+(8, 0.0446986)
+(16, 0.110759)
+(32, 0.204509)
+(64, 0.142009)
+(128, 0.0951339)
+(256, 0.0638839)
+(512, 0.0131026)
+(1024, 0.00740518)
+(2048, 0.00516743)
+(4096, 0.00557475)
+(8192, 0.00862651)
+(16384, 0.00288858)
+(32768, 0.003621)
+(65536, 0.00235452)
+(131072, 0.00147481)
+(262144, 0.000795791)
+(524288, 0.000504595)*/
+
+//]
+ }
+ {
+//[test_ks_gen2
+ typedef boost::math::normal_distribution<> dist_;
+ typedef dist_::value_type val_;
+ typedef boost::normal_distribution<> random_;
+ typedef boost::mt19937 urng_;
+ typedef boost::variate_generator<urng_&, random_> vg_;
+ const val_ sd = 1.0;
+ dist_ dist( mean, sd );
+ urng_ urng;
+ vg_ vg( urng, random_( mean ) );
+
+ os << "normal(" << mean << ',' << sd << ')' << std::endl;
+ // If vg draws from dist, convergence to zero is expected
+ std::generate_n(
+ std::ostream_iterator<boost::format>( os, "\n" ),
+ size,
+ ecdf::aux_::make_kolmogorov_smirnov_generator( vg, dist )
+ );
+ os << std::endl;
+/*
+normal(1,1)
+(1, 0.415493)
+(2, 0.415493)
+(4, 0.189905)
+(8, 0.192415)
+(16, 0.102303)
+(32, 0.0986652)
+(64, 0.0728838)
+(128, 0.0572596)
+(256, 0.0362369)
+(512, 0.034244)
+(1024, 0.0172237)
+(2048, 0.0143129)
+(4096, 0.0174088)
+(8192, 0.0108239)
+(16384, 0.00705805)
+(32768, 0.00438796)
+(65536, 0.00198669)
+(131072, 0.00244563)
+(262144, 0.00122075)
+(524288, 0.00111729)*/
+//]
+ }
+}

Added: sandbox/acc_ecdf/libs/accumulators/ecdf/test/ks_gen.h
==============================================================================
--- (empty file)
+++ sandbox/acc_ecdf/libs/accumulators/ecdf/test/ks_gen.h 2011-07-04 12:22:14 EDT (Mon, 04 Jul 2011)
@@ -0,0 +1,22 @@
+///////////////////////////////////////////////////////////////////////////////
+// accumulator_ecdf //
+// //
+// Copyright (C) 2005 Eric Niebler //
+// Copyright (C) 2011 Erwann Rogard //
+// Software License, Version 1.0. (See accompanying file //
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
+///////////////////////////////////////////////////////////////////////////////
+#ifndef LIBS_ACCUMULATORS_ECDF_KS_GEN_H_ER_2011
+#define LIBS_ACCUMULATORS_ECDF_KS_GEN_H_ER_2011
+#include <ostream>
+
+void test_ks_gen(
+ std::ostream& os,
+ double mean = 1.0,
+ long n = 1,
+ long factor = 2,
+ long size = 20
+);
+
+#endif
+

Deleted: sandbox/acc_ecdf/libs/accumulators/ecdf/test/ks_sim.cpp
==============================================================================
--- sandbox/acc_ecdf/libs/accumulators/ecdf/test/ks_sim.cpp 2011-07-04 12:22:14 EDT (Mon, 04 Jul 2011)
+++ (empty file)
@@ -1 +0,0 @@
-// TODO remove file
\ No newline at end of file

Deleted: sandbox/acc_ecdf/libs/accumulators/ecdf/test/ks_sim.h
==============================================================================
--- sandbox/acc_ecdf/libs/accumulators/ecdf/test/ks_sim.h 2011-07-04 12:22:14 EDT (Mon, 04 Jul 2011)
+++ (empty file)
@@ -1 +0,0 @@
-// TODO remove file

Added: sandbox/acc_ecdf/libs/accumulators/ecdf/test/pdf.cpp
==============================================================================
--- (empty file)
+++ sandbox/acc_ecdf/libs/accumulators/ecdf/test/pdf.cpp 2011-07-04 12:22:14 EDT (Mon, 04 Jul 2011)
@@ -0,0 +1,63 @@
+///////////////////////////////////////////////////////////////////////////////
+// accumulator_ecdf //
+// //
+// Copyright (C) 2005 Eric Niebler //
+// Copyright (C) 2011 Erwann Rogard //
+// Software License, Version 1.0. (See accompanying file //
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
+///////////////////////////////////////////////////////////////////////////////
+#include <cstddef>
+#include <boost/accumulators/accumulators.hpp>
+#include <boost/accumulators/statistics/stats.hpp>
+#include <boost/accumulators/statistics/ecdf/aux_/check.hpp>
+#include <boost/accumulators/statistics/ecdf/pdf.hpp>
+#include <libs/accumulators/ecdf/test/pdf.h>
+
+void test_ecdf_pdf()
+{
+ using namespace boost;
+ using namespace accumulators;
+
+//[test_ecdf_pdf
+ typedef double float_;
+
+ accumulator_set<
+ int,
+ stats<ecdf::tag::pdf<float_> >
+ > acc;
+
+ // Layout is chosen for its clarify, but there is no need to assume a
+ // particular ordering
+ acc( 1 );
+ acc( 2 ); acc( 2 );
+ acc( 3 ); acc( 3 ); acc( 3 );
+
+ typedef numeric::bounds<float_> bounds_;
+ typedef numeric::converter<std::size_t, float_> converter_;
+
+ float_ n = converter_::convert( count( acc ) );
+ float_ result, benchmark, eps = bounds_::smallest();
+
+ result = ecdf::pdf<float_>( acc , 0 );
+ benchmark = converter_::convert( 0 ) / n;
+ BOOST_ACCUMULATORS_ECDF_CHECK( fabs( result - benchmark ) < eps );
+
+ result = ecdf::pdf<float_>( acc , 1 );
+ benchmark = converter_::convert( 1 ) / n;
+ BOOST_ACCUMULATORS_ECDF_CHECK( fabs( result - benchmark ) < eps );
+
+ result = ecdf::pdf<float_>( acc , 2 );
+ benchmark = converter_::convert( 2 ) / n;
+ BOOST_ACCUMULATORS_ECDF_CHECK( fabs( result - benchmark ) < eps );
+
+ result = ecdf::pdf<float_>( acc , 3 );
+ benchmark = converter_::convert( 3 ) / n;
+ BOOST_ACCUMULATORS_ECDF_CHECK( fabs( result - benchmark ) < eps );
+
+ result = ecdf::pdf<float_>( acc , 4 );
+ benchmark = converter_::convert( 0 ) / n;
+ BOOST_ACCUMULATORS_ECDF_CHECK( fabs( result - benchmark ) < eps );
+
+//]
+
+}
\ No newline at end of file

Added: sandbox/acc_ecdf/libs/accumulators/ecdf/test/pdf.h
==============================================================================
--- (empty file)
+++ sandbox/acc_ecdf/libs/accumulators/ecdf/test/pdf.h 2011-07-04 12:22:14 EDT (Mon, 04 Jul 2011)
@@ -0,0 +1,11 @@
+///////////////////////////////////////////////////////////////////////////////
+// accumulator_ecdf //
+// //
+// Copyright (C) 2005 Eric Niebler //
+// Copyright (C) 2011 Erwann Rogard //
+// Software License, Version 1.0. (See accompanying file //
+// LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) //
+///////////////////////////////////////////////////////////////////////////////
+
+
+void test_ecdf_pdf();

Added: sandbox/acc_ecdf/libs/accumulators/ecdf/test/unit_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/acc_ecdf/libs/accumulators/ecdf/test/unit_test.cpp 2011-07-04 12:22:14 EDT (Mon, 04 Jul 2011)
@@ -0,0 +1,29 @@
+///////////////////////////////////////////////////////////////////////////////
+// acc_ecdf //
+// //
+// Copyright 2010 Erwann Rogard. Distributed under 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) //
+///////////////////////////////////////////////////////////////////////////////
+#include <boost/test/test_tools.hpp>
+#define BOOST_ACCUMULATORS_ECDF_CHECK( p ) BOOST_CHECK( p )
+#include <libs/accumulators/ecdf/test/count.cpp>
+#include <libs/accumulators/ecdf/test/cumulative_count.cpp>
+#include <libs/accumulators/ecdf/test/pdf.cpp>
+#include <libs/accumulators/ecdf/test/cdf.cpp>
+#include <libs/accumulators/ecdf/test/kolmogorov_smirnov_statistic.cpp>
+
+#include <boost/test/unit_test.hpp>
+using boost::unit_test::test_suite;
+
+test_suite* init_unit_test_suite( int argc, char* argv[] )
+{
+ test_suite* test = BOOST_TEST_SUITE( "ECDF" );
+ test->add( BOOST_TEST_CASE( &test_ecdf_count ) );
+ test->add( BOOST_TEST_CASE( &test_ecdf_cumulative_count ) );
+ test->add( BOOST_TEST_CASE( &test_ecdf_pdf ) );
+ test->add( BOOST_TEST_CASE( &test_ecdf_cdf ) );
+ test->add( BOOST_TEST_CASE( &test_ecdf_kolmogorov_smirnov_statistic ) );
+ return test;
+}
+


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