|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r58168 - in sandbox/statistics/adaptive_rejection_sampling: boost/ars/function boost/ars/test libs/ars libs/ars/doc libs/ars/example
From: erwann.rogard_at_[hidden]
Date: 2009-12-05 20:14:38
Author: e_r
Date: 2009-12-05 20:14:38 EST (Sat, 05 Dec 2009)
New Revision: 58168
URL: http://svn.boost.org/trac/boost/changeset/58168
Log:
m
Text files modified:
sandbox/statistics/adaptive_rejection_sampling/boost/ars/function/adaptor.hpp | 4 +-
sandbox/statistics/adaptive_rejection_sampling/boost/ars/test/gamma_distribution.hpp | 9 ++--
sandbox/statistics/adaptive_rejection_sampling/boost/ars/test/standard_distribution.hpp | 70 +++++++++++++++++++++++++++------------
sandbox/statistics/adaptive_rejection_sampling/libs/ars/doc/readme.txt | 1
sandbox/statistics/adaptive_rejection_sampling/libs/ars/example/standard_distribution.cpp | 5 +-
sandbox/statistics/adaptive_rejection_sampling/libs/ars/main.cpp | 2
6 files changed, 58 insertions(+), 33 deletions(-)
Modified: sandbox/statistics/adaptive_rejection_sampling/boost/ars/function/adaptor.hpp
==============================================================================
--- sandbox/statistics/adaptive_rejection_sampling/boost/ars/function/adaptor.hpp (original)
+++ sandbox/statistics/adaptive_rejection_sampling/boost/ars/function/adaptor.hpp 2009-12-05 20:14:38 EST (Sat, 05 Dec 2009)
@@ -53,12 +53,12 @@
value_type& log_pdf,
value_type& dlog_pdf
)const{
- log_pdf = statistics::detail::log_unnormalized_pdf(
+ log_pdf = log_unnormalized_pdf(
this->distribution(),
x
);
- dlog_pdf = statistics::detail::derivative_log_unnormalized_pdf(
+ dlog_pdf = derivative_log_unnormalized_pdf(
this->distribution(),
x
);
Modified: sandbox/statistics/adaptive_rejection_sampling/boost/ars/test/gamma_distribution.hpp
==============================================================================
--- sandbox/statistics/adaptive_rejection_sampling/boost/ars/test/gamma_distribution.hpp (original)
+++ sandbox/statistics/adaptive_rejection_sampling/boost/ars/test/gamma_distribution.hpp 2009-12-05 20:14:38 EST (Sat, 05 Dec 2009)
@@ -11,7 +11,6 @@
#include <string>
#include <boost/random/mersenne_twister.hpp>
#include <boost/statistics/detail/distribution_toolkit/distributions/gamma/include.hpp>
-#include <boost/statistics/detail/distribution_toolkit/data/generate_n_sample_cdf.hpp>
#include <boost/ars/test/standard_distribution.hpp>
namespace boost{
@@ -58,10 +57,10 @@
init_0,
init_1,
urng,
- n1, // 1e2
- n2, // 10
- n3, // 1
- n4, // 10
+ n1,
+ n2,
+ n3,
+ n4,
n_max_reject,
out
);
Modified: sandbox/statistics/adaptive_rejection_sampling/boost/ars/test/standard_distribution.hpp
==============================================================================
--- sandbox/statistics/adaptive_rejection_sampling/boost/ars/test/standard_distribution.hpp (original)
+++ sandbox/statistics/adaptive_rejection_sampling/boost/ars/test/standard_distribution.hpp 2009-12-05 20:14:38 EST (Sat, 05 Dec 2009)
@@ -20,13 +20,22 @@
#include <boost/static_assert.hpp>
#include <boost/format.hpp>
#include <boost/range.hpp>
+#include <boost/lambda/lambda.hpp>
+#include <boost/lambda/bind.hpp>
#include <boost/numeric/conversion/converter.hpp>
#include <boost/iterator/counting_iterator.hpp>
#include <boost/assign/std/vector.hpp>
+#include <boost/fusion/include/make_map.hpp>
+#include <boost/fusion/include/at_key.hpp>
+
+#include <boost/statistics/detail/distribution_common/meta/random/generator.hpp>
+#include <boost/statistics/detail/distribution_common/meta/value.hpp>
+#include <boost/statistics/detail/non_parametric/kolmogorov_smirnov/statistic.hpp>
+
#include <boost/random/mersenne_twister.hpp>
#include <boost/random/variate_generator.hpp>
-#include <boost/random/normal_distribution.hpp>
+//#include <boost/random/normal_distribution.hpp>
#include <boost/random/ref_distribution.hpp>
//#include <boost/ars/functional/standard_distribution.hpp>
@@ -35,8 +44,6 @@
#include <boost/ars/proposal_sampler.hpp>
#include <boost/ars/sampler.hpp>
-#include <boost/statistics/detail/distribution_toolkit/data/sample_cdf.hpp>
-
namespace boost{
namespace statistics{
namespace detail{
@@ -67,9 +74,10 @@
using namespace boost;
using namespace math;
using namespace assign;
+ namespace dist = boost::statistics::detail::distribution;
typedef std::string str_;
typedef std::runtime_error err_;
- typedef typename D::value_type val_;
+ typedef typename dist::meta::value<D>::type val_;
typedef std::vector<val_> vals_;
typedef ars::function::adaptor<D> fun_t;
@@ -78,37 +86,55 @@
typedef random::ref_distribution<ars_&> ref_ars_;
typedef variate_generator<U&,ref_ars_> vg_ars_;
- typedef statistics::detail::distribution::toolkit::sample_cdf<val_> sc_;
-
+ typedef boost::mpl::int_<0> key1_;
+ typedef boost::mpl::int_<1> key2_;
+ typedef typename boost::fusion::result_of::make_map<
+ key1_,key2_,val_,val_
+ >::type data_;
+ typedef non_parametric::kolmogorov_smirnov::statistic<val_,key1_,key2_> ks_;
+ typedef std::vector<data_> dataset_;
+ dataset_ dataset;
+ ks_ ks;
ars_ ars;
ars.set_function(x_min, x_max, fun_t(mdist));
-
- sc_ sc;
-
{
- format f(
- "ars initialized every %1% with init_0 = %2% and init_1 = %3%"
- );
+ static const str_ str
+ = "ars initialized every %1% with init_0 = %2% and init_1 = %3%";
+ format f(str);
f%n3%init_0%init_1;
os << f.str() << std::endl;
- os << "(Kolmogorov-statistic, # rejections per draw): " << std::endl;
+ os << description(mdist) << std::endl;
+ {
+ format f("(%1%,%2%)");
+ f%ks.description_header%"rejection rate";
+ os
+ << f.str()
+ << std::endl;
+ }
}
long unsigned n_reject;
try{
for(unsigned i1 = 0; i1<n1; i1++){
- sc.clear();
+ dataset.clear();
n_reject = 0;
+
for(unsigned i2 = 0; i2<n2; i2++){
try{
ars.initialize(init_0,init_1);
vg_ars_ vg_ars(urng,ref_ars_(ars));
- boost::generate_n(
- sc,
- n3,
- vg_ars,
- mdist
- );
- // Withos ref_s_, n would be reset to 0
+ dataset.reserve(dataset.size()+n3);
+ for(unsigned i = 0; i<n3; i++)
+ {
+ val_ x = vg_ars();
+ dataset.push_back(
+ boost::fusion::make_map<key1_,key2_>(
+ x,
+ cdf(mdist,x)
+ )
+ );
+ }
+ ks(boost::begin(dataset),boost::end(dataset));
+ // Without ref_s_, n would be reset to 0
n_reject += (
(vg_ars.distribution()).distribution()
).n_reject();
@@ -122,7 +148,7 @@
= static_cast<val_>(n_reject)/static_cast<val_>(n3*n2);
os
<< '('
- << sc
+ << ks.description()
<< ','
<< rate
<< ')'
Modified: sandbox/statistics/adaptive_rejection_sampling/libs/ars/doc/readme.txt
==============================================================================
--- sandbox/statistics/adaptive_rejection_sampling/libs/ars/doc/readme.txt (original)
+++ sandbox/statistics/adaptive_rejection_sampling/libs/ars/doc/readme.txt 2009-12-05 20:14:38 EST (Sat, 05 Dec 2009)
@@ -31,6 +31,7 @@
[ History ]
+Dec 4 2009 : misc changes due to updated dependencies
Sept 2009 : standard_distribution.hpp modified due to changes described in
sandbox/distribution_toolkit's history.
July 2009 : Previous package superseded by adaptive_rejection_sampling
Modified: sandbox/statistics/adaptive_rejection_sampling/libs/ars/example/standard_distribution.cpp
==============================================================================
--- sandbox/statistics/adaptive_rejection_sampling/libs/ars/example/standard_distribution.cpp (original)
+++ sandbox/statistics/adaptive_rejection_sampling/libs/ars/example/standard_distribution.cpp 2009-12-05 20:14:38 EST (Sat, 05 Dec 2009)
@@ -8,7 +8,6 @@
#include <iostream>
#include <boost/statistics/detail/distribution_toolkit/distributions/gamma/include.hpp>
#include <boost/statistics/detail/distribution_toolkit/distributions/normal/include.hpp>
-#include <boost/statistics/detail/distribution_toolkit/fwd_math/cdf.hpp>
#include <boost/ars/test/gamma_distribution.hpp>
#include <boost/ars/test/normal_distribution.hpp>
#include <libs/ars/example/standard_distribution.h>
@@ -27,10 +26,10 @@
typedef double value_;
- const unsigned n1 = 6e0; // # loops
+ const unsigned n1 = 1e1; // # loops
const unsigned n2 = 1e1; // # subsamples on first loop
const unsigned n3 = 1e0; // size of subsample
- const unsigned n4 = 1e1; // At each loop, n2 *= n4
+ const unsigned n4 = 2e0; // At each loop, n2 *= n4
const unsigned max_n_reject = 10;
// The initial values are chosen to test the robustness of the
Modified: sandbox/statistics/adaptive_rejection_sampling/libs/ars/main.cpp
==============================================================================
--- sandbox/statistics/adaptive_rejection_sampling/libs/ars/main.cpp (original)
+++ sandbox/statistics/adaptive_rejection_sampling/libs/ars/main.cpp 2009-12-05 20:14:38 EST (Sat, 05 Dec 2009)
@@ -11,7 +11,7 @@
int main(){
- example_search_reflection(std::cout);
+ //example_search_reflection(std::cout);
example_standard_distribution(std::cout);
return 0;
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