|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r56895 - in sandbox/statistics/importance_weights: boost/importance_weights/algorithm libs/importance_weights/doc libs/importance_weights/example libs/importance_weights/src
From: erwann.rogard_at_[hidden]
Date: 2009-10-16 00:51:03
Author: e_r
Date: 2009-10-16 00:51:01 EDT (Fri, 16 Oct 2009)
New Revision: 56895
URL: http://svn.boost.org/trac/boost/changeset/56895
Log:
m
Text files modified:
sandbox/statistics/importance_weights/boost/importance_weights/algorithm/apply_exp_offset.hpp | 8 +++++---
sandbox/statistics/importance_weights/boost/importance_weights/algorithm/effective_sample_size.hpp | 8 +++++---
sandbox/statistics/importance_weights/boost/importance_weights/algorithm/find_scale_to_finite_sum.hpp | 8 +++++---
sandbox/statistics/importance_weights/boost/importance_weights/algorithm/maximal_finite_sums.hpp | 8 +++++---
sandbox/statistics/importance_weights/boost/importance_weights/algorithm/prepare_weights.hpp | 28 +++++++++-------------------
sandbox/statistics/importance_weights/boost/importance_weights/algorithm/scale_to_finite_sum.hpp | 8 +++++---
sandbox/statistics/importance_weights/libs/importance_weights/doc/readme.txt | 10 ++++++----
sandbox/statistics/importance_weights/libs/importance_weights/example/scale_to_finite_sum.cpp | 4 ++--
sandbox/statistics/importance_weights/libs/importance_weights/example/scale_to_finite_sum.h | 2 +-
sandbox/statistics/importance_weights/libs/importance_weights/src/main.cpp | 2 +-
10 files changed, 44 insertions(+), 42 deletions(-)
Modified: sandbox/statistics/importance_weights/boost/importance_weights/algorithm/apply_exp_offset.hpp
==============================================================================
--- sandbox/statistics/importance_weights/boost/importance_weights/algorithm/apply_exp_offset.hpp (original)
+++ sandbox/statistics/importance_weights/boost/importance_weights/algorithm/apply_exp_offset.hpp 2009-10-16 00:51:01 EDT (Fri, 16 Oct 2009)
@@ -1,12 +1,12 @@
///////////////////////////////////////////////////////////////////////////////
-// importance_weights::algorithm::apply_exp_offset //
+// statistics::importance_weights::algorithm::apply_exp_offset //
// //
// Copyright 2009 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) //
///////////////////////////////////////////////////////////////////////////////
-#ifndef BOOST_IMPORTANCE_WEIGHTS_ALGORITHM_APPLY_EXP_OFFSET_HPP_ER_2009
-#define BOOST_IMPORTANCE_WEIGHTS_ALGORITHM_APPLY_EXP_OFFSET_HPP_ER_2009
+#ifndef BOOST_STATISTICS_IMPORTANCE_WEIGHTS_ALGORITHM_APPLY_EXP_OFFSET_HPP_ER_2009
+#define BOOST_STATISTICS_IMPORTANCE_WEIGHTS_ALGORITHM_APPLY_EXP_OFFSET_HPP_ER_2009
#include <cmath>
#include <algorithm>
#include <boost/lambda/lambda.hpp>
@@ -14,6 +14,7 @@
#include <boost/math/tools/precision.hpp>
namespace boost{
+namespace statistics{
namespace importance_weights{
// Returns The smallest value, c, s/t *i + c <= t, i in [b_w,e_w)
@@ -55,6 +56,7 @@
}
}// importance_weights
+}// statistics
}// boost
#endif
\ No newline at end of file
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-10-16 00:51:01 EDT (Fri, 16 Oct 2009)
@@ -1,12 +1,12 @@
///////////////////////////////////////////////////////////////////////////////
-// importance_weights::effective_sample_size.hpp //
+// statistics::importance_weights::effective_sample_size.hpp //
// //
// Copyright 2009 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) //
///////////////////////////////////////////////////////////////////////////////
-#ifndef BOOST_IMPORTANCE_WEIGHTS_ALGORITHM_EFFECTIVE_SAMPLE_SIZE_HPP_ER_2009
-#define BOOST_IMPORTANCE_WEIGHTS_ALGORITHM_EFFECTIVE_SAMPLE_SIZE_HPP_ER_2009
+#ifndef BOOST_STATISTICS_IMPORTANCE_WEIGHTS_ALGORITHM_EFFECTIVE_SAMPLE_SIZE_HPP_ER_2009
+#define BOOST_STATISTICS_IMPORTANCE_WEIGHTS_ALGORITHM_EFFECTIVE_SAMPLE_SIZE_HPP_ER_2009
#include <algorithm>
#include <numeric>
#include <iterator>
@@ -17,6 +17,7 @@
#include <boost/functional/mean_var_accumulator.hpp>
namespace boost{
+namespace statistics{
namespace importance_weights{
// Finds the number of iid observations whose standard error equates that
@@ -68,6 +69,7 @@
}
}// importance_weights
+}// statistics
}// boost
#endif
\ No newline at end of file
Modified: sandbox/statistics/importance_weights/boost/importance_weights/algorithm/find_scale_to_finite_sum.hpp
==============================================================================
--- sandbox/statistics/importance_weights/boost/importance_weights/algorithm/find_scale_to_finite_sum.hpp (original)
+++ sandbox/statistics/importance_weights/boost/importance_weights/algorithm/find_scale_to_finite_sum.hpp 2009-10-16 00:51:01 EDT (Fri, 16 Oct 2009)
@@ -1,12 +1,12 @@
///////////////////////////////////////////////////////////////////////////////
-// importance_weights::algorithm::find_scale_to_finite_sum.hpp //
+// statistics::importance_weights::algorithm::find_scale_to_finite_sum.hpp //
// //
// Copyright 2009 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) //
///////////////////////////////////////////////////////////////////////////////
-#ifndef BOOST_IMPORTANCE_WEIGHTS_ALGORITHM_FIND_SCALE_TO_FINITE_SUM_HPP_ER_2009
-#define BOOST_IMPORTANCE_WEIGHTS_ALGORITHM_FIND_SCALE_TO_FINITE_SUM_HPP_ER_2009
+#ifndef BOOST_STATISTICS_IMPORTANCE_WEIGHTS_ALGORITHM_FIND_SCALE_TO_FINITE_SUM_HPP_ER_2009
+#define BOOST_STATISTICS_IMPORTANCE_WEIGHTS_ALGORITHM_FIND_SCALE_TO_FINITE_SUM_HPP_ER_2009
#include <cmath>
#include <numeric>
#include <stdexcept>
@@ -19,6 +19,7 @@
#include <boost/importance_weights/algorithm/maximal_finite_sums.hpp>
namespace boost{
+namespace statistics{
namespace importance_weights{
// Finds c such that the sum over sum{*i/c, i in [b,e)} < inf using the
@@ -134,6 +135,7 @@
}
}// importance_weights
+}// statistics
}// boost
#endif
\ No newline at end of file
Modified: sandbox/statistics/importance_weights/boost/importance_weights/algorithm/maximal_finite_sums.hpp
==============================================================================
--- sandbox/statistics/importance_weights/boost/importance_weights/algorithm/maximal_finite_sums.hpp (original)
+++ sandbox/statistics/importance_weights/boost/importance_weights/algorithm/maximal_finite_sums.hpp 2009-10-16 00:51:01 EDT (Fri, 16 Oct 2009)
@@ -1,16 +1,17 @@
///////////////////////////////////////////////////////////////////////////////
-// importance_weights::algorithm::maximal_finite_sums.hpp //
+// statistics::importance_weights::algorithm::maximal_finite_sums.hpp //
// //
// Copyright 2009 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) //
///////////////////////////////////////////////////////////////////////////////
-#ifndef BOOST_IMPORTANCE_WEIGHTS_ALGORITHM_MAXIMAL_FINITE_SUMS_HPP_ER_2009
-#define BOOST_IMPORTANCE_WEIGHTS_ALGORITHM_MAXIMAL_FINITE_SUMS_HPP_ER_2009
+#ifndef BOOST_STATISTICS_IMPORTANCE_WEIGHTS_ALGORITHM_MAXIMAL_FINITE_SUMS_HPP_ER_2009
+#define BOOST_STATISTICS_IMPORTANCE_WEIGHTS_ALGORITHM_MAXIMAL_FINITE_SUMS_HPP_ER_2009
#include <boost/iterator/iterator_traits.hpp>
#include <boost/math/special_functions/fpclassify.hpp>
namespace boost{
+namespace statistics{
namespace importance_weights{
// Breaks down the summation of *i, i in [b,e) into maximal finite amounts,
@@ -35,6 +36,7 @@
};
}// importance_weights
+}// statistics
}// boost
#endif
\ No newline at end of file
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-10-16 00:51:01 EDT (Fri, 16 Oct 2009)
@@ -1,12 +1,12 @@
///////////////////////////////////////////////////////////////////////////////
-// importance_weights::algorithm::prepare_weights.hpp //
+// statistics::importance_weights::algorithm::prepare_weights.hpp //
// //
// Copyright 2009 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) //
///////////////////////////////////////////////////////////////////////////////
-#ifndef BOOST_IMPORTANCE_WEIGHTS_ALGORITHM_PREPARE_WEIGHTS_HPP_ER_2009
-#define BOOST_IMPORTANCE_WEIGHTS_ALGORITHM_PREPARE_WEIGHTS_HPP_ER_2009
+#ifndef BOOST_STATISTICS_IMPORTANCE_WEIGHTS_ALGORITHM_PREPARE_WEIGHTS_HPP_ER_2009
+#define BOOST_STATISTICS_IMPORTANCE_WEIGHTS_ALGORITHM_PREPARE_WEIGHTS_HPP_ER_2009
#include <iterator>
#include <functional>
#include <boost/format.hpp>
@@ -19,6 +19,7 @@
#include <boost/importance_weights/algorithm/effective_sample_size.hpp>
namespace boost{
+namespace statistics{
namespace importance_weights{
// Warning: read side effects carefully.
@@ -46,12 +47,10 @@
// [ Side effect ]
// 1) w <- exp(lw+offset)
// 2) if needed, w <- w/c such that sum{w} < inf
- // Deprecated: 3) Sorts [b_w,e_w) in decr order, and [b_p,e_p) accordingly
- template<typename ItW,typename ItP>
+ template<typename ItW>
void operator()(
ItW b_w, // log( unnormalized weights )
- ItW e_w,
- ItP b_p // proposal values
+ ItW e_w
);
public:
@@ -111,12 +110,11 @@
offset(zero),scaling_factor(zero),pc_ess(zero),pc_lt_eps(zero){}
template<typename T>
- template<typename ItW,typename ItP>
+ template<typename ItW>
void
prepare_weights<T>::operator()(
ItW b_w,
- ItW e_w,
- ItP b_p
+ ItW e_w
){
offset = apply_exp_offset(
b_w,
@@ -124,15 +122,6 @@
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
- //);
-
// if max_log is small enough (which costs precision), this does not
// nothing i.e. scaling_factor = 1
scaling_factor = scale_to_finite_sum(
@@ -165,6 +154,7 @@
}
}// importance_weights
+}// statistics
}// boost
#endif
\ No newline at end of file
Modified: sandbox/statistics/importance_weights/boost/importance_weights/algorithm/scale_to_finite_sum.hpp
==============================================================================
--- sandbox/statistics/importance_weights/boost/importance_weights/algorithm/scale_to_finite_sum.hpp (original)
+++ sandbox/statistics/importance_weights/boost/importance_weights/algorithm/scale_to_finite_sum.hpp 2009-10-16 00:51:01 EDT (Fri, 16 Oct 2009)
@@ -1,18 +1,19 @@
///////////////////////////////////////////////////////////////////////////////
-// importance_weights::algorithm::scale_to_finite_sum.hpp //
+// statistics::importance_weights::algorithm::scale_to_finite_sum.hpp //
// //
// Copyright 2009 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) //
///////////////////////////////////////////////////////////////////////////////
-#ifndef BOOST_IMPORTANCE_WEIGHTS_ALGORITHM_SCALE_TO_FINITE_SUM_HPP_ER_2009
-#define BOOST_IMPORTANCE_WEIGHTS_ALGORITHM_SCALE_TO_FINITE_SUM_HPP_ER_2009
+#ifndef BOOST_STATISTICS_IMPORTANCE_WEIGHTS_ALGORITHM_SCALE_TO_FINITE_SUM_HPP_ER_2009
+#define BOOST_STATISTICS_IMPORTANCE_WEIGHTS_ALGORITHM_SCALE_TO_FINITE_SUM_HPP_ER_2009
#include <numeric>
#include <boost/lambda/lambda.hpp>
#include <boost/range.hpp>
#include <boost/importance_weights/algorithm/find_scale_to_finite_sum.hpp>
namespace boost{
+namespace statistics{
namespace importance_weights{
// Scales each element [b,e) by the smallest factor, c, such that the sum
@@ -67,6 +68,7 @@
}
}// importance_weights
+}// statistics
}// boost
#endif
\ No newline at end of file
Modified: sandbox/statistics/importance_weights/libs/importance_weights/doc/readme.txt
==============================================================================
--- sandbox/statistics/importance_weights/libs/importance_weights/doc/readme.txt (original)
+++ sandbox/statistics/importance_weights/libs/importance_weights/doc/readme.txt 2009-10-16 00:51:01 EDT (Fri, 16 Oct 2009)
@@ -1,5 +1,5 @@
//////////////////////////////////////////////////////////////////////////////
-// importance_weights::doc::readme //
+// statistics::importance_weights::doc::readme //
// //
// (C) Copyright 2009 Erwann Rogard //
// Use, modification and distribution are subject to the //
@@ -28,8 +28,7 @@
[ Dependencies ]
/usr/local/boost_1_39_0/
-/sandbox/statistics/non_param/
-/sandbox/statistics/binary_op/
+/sandbox/statistics/empirical_cdf/
/sandbox/statistics/functional/
[ Sources ]
@@ -43,7 +42,10 @@
[ History ]
-July 2009 : Current version
+Sep 3 2009 :
+ - replaced importance_weights by statistics::importance_weights
+ - simplified the interface of prepare_weights
+July 2009 : Creation
[ Output ]
Modified: sandbox/statistics/importance_weights/libs/importance_weights/example/scale_to_finite_sum.cpp
==============================================================================
--- sandbox/statistics/importance_weights/libs/importance_weights/example/scale_to_finite_sum.cpp (original)
+++ sandbox/statistics/importance_weights/libs/importance_weights/example/scale_to_finite_sum.cpp 2009-10-16 00:51:01 EDT (Fri, 16 Oct 2009)
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
-// importance_weights::example::scale_to_finite_sum.cpp //
+// statistics::importance_weights::example::scale_to_finite_sum.cpp //
// //
// Copyright 2009 Erwann Rogard. Distributed under the Boost //
// Software License, Version 1.0. (See accompanying file //
@@ -39,7 +39,7 @@
}
// Computations
- val_ c = importance_weights::scale_to_finite_sum(
+ val_ c = statistics::importance_weights::scale_to_finite_sum(
boost::begin(vec_in),
boost::end(vec_in)
);
Modified: sandbox/statistics/importance_weights/libs/importance_weights/example/scale_to_finite_sum.h
==============================================================================
--- sandbox/statistics/importance_weights/libs/importance_weights/example/scale_to_finite_sum.h (original)
+++ sandbox/statistics/importance_weights/libs/importance_weights/example/scale_to_finite_sum.h 2009-10-16 00:51:01 EDT (Fri, 16 Oct 2009)
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
-// importance_weights::example::scale_to_finite_sum.h //
+// statistics::importance_weights::example::scale_to_finite_sum.h //
// //
// Copyright 2009 Erwann Rogard. Distributed under the Boost //
// Software License, Version 1.0. (See accompanying file //
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-10-16 00:51:01 EDT (Fri, 16 Oct 2009)
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
-// importance_weights::example::scale_to_finite_sum.h //
+// statistics::importance_weights::example::scale_to_finite_sum.h //
// //
// Copyright 2009 Erwann Rogard. Distributed under the Boost //
// Software License, Version 1.0. (See accompanying file //
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