|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r55981 - in sandbox/statistics/importance_weights: boost/importance_weights/algorithm libs/importance_weights/src
From: erwann.rogard_at_[hidden]
Date: 2009-09-02 21:49:18
Author: e_r
Date: 2009-09-02 21:49:17 EDT (Wed, 02 Sep 2009)
New Revision: 55981
URL: http://svn.boost.org/trac/boost/changeset/55981
Log:
m
Text files modified:
sandbox/statistics/importance_weights/boost/importance_weights/algorithm/effective_sample_size.hpp | 7 ++++++-
sandbox/statistics/importance_weights/boost/importance_weights/algorithm/prepare_weights.hpp | 40 ++++++++++++++++++++++++----------------
sandbox/statistics/importance_weights/libs/importance_weights/src/main.cpp | 2 +-
3 files changed, 31 insertions(+), 18 deletions(-)
Modified: sandbox/statistics/importance_weights/boost/importance_weights/algorithm/effective_sample_size.hpp
==============================================================================
--- sandbox/statistics/importance_weights/boost/importance_weights/algorithm/effective_sample_size.hpp (original)
+++ sandbox/statistics/importance_weights/boost/importance_weights/algorithm/effective_sample_size.hpp 2009-09-02 21:49:17 EDT (Wed, 02 Sep 2009)
@@ -50,13 +50,18 @@
static val_ one = static_cast<val_>(1);
acc_ acc;
- std::for_each(b_w,e_w, lambda::bind<void>(boost::ref(acc),lambda::_1));
+ std::for_each(
+ b_w,
+ e_w,
+ lambda::bind<void>(boost::ref(acc),lambda::_1)
+ );
val_ v = static_cast<val_>(
boost::accumulators::variance(acc)
);
val_ c = static_cast<val_>(
boost::accumulators::mean(acc)
);
+
v /= (c*c);
return one / (one + v);
Modified: sandbox/statistics/importance_weights/boost/importance_weights/algorithm/prepare_weights.hpp
==============================================================================
--- sandbox/statistics/importance_weights/boost/importance_weights/algorithm/prepare_weights.hpp (original)
+++ sandbox/statistics/importance_weights/boost/importance_weights/algorithm/prepare_weights.hpp 2009-09-02 21:49:17 EDT (Wed, 02 Sep 2009)
@@ -9,10 +9,11 @@
#define BOOST_IMPORTANCE_WEIGHTS_ALGORITHM_PREPARE_WEIGHTS_HPP_ER_2009
#include <iterator>
#include <functional>
+#include <boost/format.hpp>
#include <boost/lambda/lambda.hpp>
#include <boost/math/tools/precision.hpp>
-#include <boost/binary_op/algorithm/sort_on_head.hpp>
-#include <boost/non_param/algorithm/proportion_less_than.hpp>
+//#include <boost/binary_op/algorithm/sort_on_head.hpp>
+#include <boost/statistics/empirical_cdf/algorithm/proportion_less_than.hpp>
#include <boost/importance_weights/algorithm/apply_exp_offset.hpp>
#include <boost/importance_weights/algorithm/scale_to_finite_sum.hpp>
#include <boost/importance_weights/algorithm/effective_sample_size.hpp>
@@ -45,7 +46,7 @@
// [ Side effect ]
// 1) w <- exp(lw+offset)
// 2) if needed, w <- w/c such that sum{w} < inf
- // 3) Sorts [b_w,e_w) in decr order, and [b_p,e_p) accordingly
+ // Deprecated: 3) Sorts [b_w,e_w) in decr order, and [b_p,e_p) accordingly
template<typename ItW,typename ItP>
void operator()(
ItW b_w, // log( unnormalized weights )
@@ -68,14 +69,18 @@
// Implementation
template<typename T>
- std::ostream& operator<<(std::ostream& out,
- const prepare_weights<T>& that){
- out
- << '(' << that.offset
- << ',' << that.scaling_factor
- << ',' << that.pc_ess
- << ',' << that.pc_lt_eps
- << ')';
+ std::ostream& operator<<(
+ std::ostream& out,
+ const prepare_weights<T>& that
+ ){
+ out <<
+ (
+ format("(%1%,%2%,%3%,%4%)")
+ % that.offset
+ % that.scaling_factor
+ % that.pc_ess
+ % that.pc_lt_eps
+ ).str();
return out;
}
@@ -119,13 +124,14 @@
max_log
);
+ // Deprecated because of discrete_distribution (see importance_sampling)
// crucial that this step precedes scale_to_finite_sum because
// finiteness is not nec preserved by reordering (non associativity)
- binary_op::sort_on_head_greater(
- b_w,
- e_w,
- b_p
- );
+ //binary_op::sort_on_head_greater(
+ // b_w,
+ // e_w,
+ // b_p
+ //);
// if max_log is small enough (which costs precision), this does not
// nothing i.e. scaling_factor = 1
@@ -146,6 +152,7 @@
value_type n_lt_eps
= static_cast<value_type>( std::distance(i_lt_eps,e_w) );
+
// Increasing max_log should decrease this number
pc_lt_eps = n_lt_eps / ( n_lt_eps + n_gt_eps ) ;
@@ -154,6 +161,7 @@
b_w,
e_w
);
+
}
}// importance_weights
Modified: sandbox/statistics/importance_weights/libs/importance_weights/src/main.cpp
==============================================================================
--- sandbox/statistics/importance_weights/libs/importance_weights/src/main.cpp (original)
+++ sandbox/statistics/importance_weights/libs/importance_weights/src/main.cpp 2009-09-02 21:49:17 EDT (Wed, 02 Sep 2009)
@@ -12,7 +12,7 @@
example_scale_to_finite_sum(std::cout);
- // See package statistics/importance_sampling for more examples.
+ // See sandbox/statistics/importance_sampling for more examples.
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