|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r72909 - sandbox/statistics/non_parametric/boost/statistics/detail/non_parametric/empirical_distribution
From: erwann.rogard_at_[hidden]
Date: 2011-07-05 07:18:05
Author: e_r
Date: 2011-07-05 07:18:03 EDT (Tue, 05 Jul 2011)
New Revision: 72909
URL: http://svn.boost.org/trac/boost/changeset/72909
Log:
cleaning up directory
Text files modified:
sandbox/statistics/non_parametric/boost/statistics/detail/non_parametric/empirical_distribution/count.hpp | 111 +++++++--------------------------------
sandbox/statistics/non_parametric/boost/statistics/detail/non_parametric/empirical_distribution/frequency.hpp | 34 +++++++-----
sandbox/statistics/non_parametric/boost/statistics/detail/non_parametric/empirical_distribution/ordered_sample.hpp | 3
3 files changed, 44 insertions(+), 104 deletions(-)
Modified: sandbox/statistics/non_parametric/boost/statistics/detail/non_parametric/empirical_distribution/count.hpp
==============================================================================
--- sandbox/statistics/non_parametric/boost/statistics/detail/non_parametric/empirical_distribution/count.hpp (original)
+++ sandbox/statistics/non_parametric/boost/statistics/detail/non_parametric/empirical_distribution/count.hpp 2011-07-05 07:18:03 EDT (Tue, 05 Jul 2011)
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
-// accumulator::statistics::empirical_distribution::count.hpp //
+// count.hpp //
// //
// Copyright 2010 Erwann Rogard. Distributed under the Boost //
// Software License, Version 1.0. (See accompanying file //
@@ -17,6 +17,7 @@
#include <boost/mpl/bool.hpp>
#include <boost/range.hpp>
+#include <boost/numeric/conversion/converter.hpp>
#include <boost/accumulators/framework/extractor.hpp>
#include <boost/accumulators/framework/accumulator_base.hpp>
@@ -31,21 +32,11 @@
namespace statistics{
namespace detail{
namespace empirical_distribution{
-
- // Usage:
- // namespace ns = empirical_distribution;
- // accumulator_set<T,stats<ns::tag::count<Cum> > > acc;
- // acc = boost:for_each(samples,acc);
- // ns::extract::count<Cum>(acc,x);
- // The result of the last statement is number of observations matching (less
- // than) x in the samples if Cum = false (true).
-
namespace impl{
// T can be an integer or a float
- template<typename T,bool Cum,typename Comp = std::less<T> >
+ template<typename T>
class count : public boost::accumulators::accumulator_base{
- typedef Comp comp_;
typedef std::size_t size_;
typedef boost::accumulators::dont_care dont_care_;
@@ -60,72 +51,20 @@
template<typename Args>
result_type result(const Args& args)const{
- sample_type key = args[boost::accumulators::sample];
- typedef typename boost::mpl::bool_<Cum> is_cum_;
- typedef boost::statistics::detail
- ::empirical_distribution::tag::ordered_sample tag_;
- return this->result_impl(
- boost::accumulators::extract_result<tag_>(
- args[boost::accumulators::accumulator]
- ),
- key,
- is_cum_()
- );
- }
-
- private:
-
- template<typename Map>
- result_type result_impl(
- Map& map,
- const sample_type& key,
- boost::mpl::bool_<false> cum
- )const{
- return (map[key]);
- }
-
- template<typename Map>
- result_type result_impl(
- Map& map,
- const sample_type& x,
- boost::mpl::bool_<true> cum
- )const{
- return std::for_each(
- boost::const_begin(map),
- this->bound(map,x),
- accumulator()
- ).value;
+ namespace ns = empirical_distribution;
+ typedef ns::tag::ordered_sample tag_;
+ return boost::accumulators::extract_result<tag_>(
+ args[ boost::accumulators::accumulator ]
+ )[
+ args[ boost::accumulators::sample ]
+ ];
}
- template<typename Map>
- typename boost::range_iterator<const Map>::type
- bound(
- const Map& map,
- const sample_type& x
- )const{
- return map.upper_bound(x);
- }
-
- struct accumulator{
- mutable size_ value;
-
- accumulator():value(0){}
- accumulator(const accumulator& that)
- :value(that.value){}
-
- template<typename Data>
- void operator()(const Data& data)const{
- value += data.second;
- }
-
- };
};
-}
-
+}// impl
namespace tag
{
- template<bool Cum>
struct count: boost::accumulators::depends_on<
boost::statistics::detail
::empirical_distribution::tag::ordered_sample
@@ -134,45 +73,39 @@
struct impl{
template<typename T,typename W>
struct apply{
- typedef boost::statistics::detail::empirical_distribution
- ::impl::count<T,Cum> type;
+ typedef detail::empirical_distribution::impl::count<T> type;
};
};
};
-}
+}// tag
namespace result_of{
- template<bool Cum,typename AccSet>
+ template<typename AccSet,typename T>
struct count{
- typedef boost::statistics::detail
- ::empirical_distribution::tag::count<Cum> tag_;
+ typedef detail::empirical_distribution::tag::count tag_;
typedef typename
boost::accumulators::detail::template
extractor_result<AccSet,tag_>::type type;
};
-}
+}// result_of
namespace extract
{
- // Usage : count<Cum>(acc,x)
- template<bool Cum,typename AccSet,typename T>
- typename boost::statistics::detail
- ::empirical_distribution::result_of::template count<Cum,AccSet>::type
+ template<typename AccSet,typename T>
+ typename detail::empirical_distribution
+ ::result_of::template count<AccSet,T>::type
count(AccSet const& acc,const T& x)
{
- typedef boost::statistics::detail
- ::empirical_distribution::tag::count<Cum> tag_;
+ namespace ed = detail::empirical_distribution;
+ typedef ed::tag::count tag_;
return boost::accumulators::extract_result<tag_>(
acc,
(boost::accumulators::sample = x)
);
}
-}
-
-using extract::count;
-
+}// extract
}// empirical_distribution
}// detail
}// statistics
Modified: sandbox/statistics/non_parametric/boost/statistics/detail/non_parametric/empirical_distribution/frequency.hpp
==============================================================================
--- sandbox/statistics/non_parametric/boost/statistics/detail/non_parametric/empirical_distribution/frequency.hpp (original)
+++ sandbox/statistics/non_parametric/boost/statistics/detail/non_parametric/empirical_distribution/frequency.hpp 2011-07-05 07:18:03 EDT (Tue, 05 Jul 2011)
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
-// accumulator::statistics::empirical_distribution::frequency.hpp //
+// frequency.hpp //
// //
// Copyright 2010 Erwann Rogard. Distributed under the Boost //
// Software License, Version 1.0. (See accompanying file //
@@ -7,6 +7,8 @@
///////////////////////////////////////////////////////////////////////////////
#ifndef BOOST_STATISTICS_DETAIL_ACCUMULATOR_STATISTICS_FREQUENCY_HPP_ER_2010
#define BOOST_STATISTICS_DETAIL_ACCUMULATOR_STATISTICS_FREQUENCY_HPP_ER_2010
+/*
+
#include <iostream> // tmp
#include <boost/mpl/placeholders.hpp>
@@ -32,18 +34,18 @@
// Usage:
// namespace ns = empirical_distribution;
- // accumulator_set<T,stats<ns::tag::count<Cum> > > acc;
+ // accumulator_set<T,stats<ns::tag::count<is_cum> > > acc;
// acc = boost:for_each(samples,acc);
- // ns::extract::count<Cum>(acc,x);
+ // ns::extract::count<is_cum>(acc,x);
// The result of the last statement is the % of observation matching (less
- // than) x in the samples if Cum = false (true).
+ // than) x in the samples if is_cum = false (true).
namespace impl{
// Frequency as percentage of the sample size
//
// Warning : See empirical_distribution::impl::count.
- template<typename T,bool Cum,typename T1>
+ template<typename T,bool is_cum,typename T1>
class frequency : public boost::accumulators::accumulator_base{
typedef std::size_t size_;
@@ -69,10 +71,10 @@
namespace tag
{
- template<bool Cum,typename T1 = double>
+ template<bool is_cum,typename T1 = double>
struct frequency
: boost::accumulators::depends_on<
- statistics::detail::empirical_distribution::tag::count<Cum>,
+ statistics::detail::empirical_distribution::tag::count<is_cum>,
boost::accumulators::tag::count
>
{
@@ -80,7 +82,7 @@
template<typename T,typename W>
struct apply{
typedef statistics::detail::empirical_distribution
- ::impl::frequency<T,Cum,T1> type;
+ ::impl::frequency<T,is_cum,T1> type;
};
};
};
@@ -88,11 +90,11 @@
namespace result_of{
- template<bool Cum,typename T1,typename AccSet>
+ template<bool is_cum,typename T1,typename AccSet>
struct frequency{
typedef boost::statistics::detail
- ::empirical_distribution::tag::frequency<Cum,T1> tag_;
+ ::empirical_distribution::tag::frequency<is_cum,T1> tag_;
typedef typename boost::accumulators
::detail::template extractor_result<AccSet,tag_>::type type;
@@ -102,10 +104,10 @@
namespace extract
{
- // Usage : frequency<Cum,T1>(acc,x)
- template<bool Cum,typename T1,typename AccSet,typename T>
+ // Usage : frequency<is_cum,T1>(acc,x)
+ template<bool is_cum,typename T1,typename AccSet,typename T>
typename boost::statistics::detail::empirical_distribution
- ::result_of::template frequency<Cum,T1,AccSet>::type
+ ::result_of::template frequency<is_cum,T1,AccSet>::type
frequency(AccSet const& acc,const T& x)
{
typedef std::size_t size_;
@@ -113,11 +115,13 @@
namespace ns = boost::statistics::detail::empirical_distribution;
- size_ i = ns::extract::count<Cum>( acc, x );
+ size_ i = ns::extract::count<is_cum>( acc, x );
size_ n = boost::accumulators::extract_result<tag_n_>( acc );
return static_cast<T1>(i)/static_cast<T1>(n);
}
+
+
}
using extract::frequency;
@@ -127,4 +131,6 @@
}// statistics
}// boost
+*/
+
#endif
Modified: sandbox/statistics/non_parametric/boost/statistics/detail/non_parametric/empirical_distribution/ordered_sample.hpp
==============================================================================
--- sandbox/statistics/non_parametric/boost/statistics/detail/non_parametric/empirical_distribution/ordered_sample.hpp (original)
+++ sandbox/statistics/non_parametric/boost/statistics/detail/non_parametric/empirical_distribution/ordered_sample.hpp 2011-07-05 07:18:03 EDT (Tue, 05 Jul 2011)
@@ -1,5 +1,5 @@
///////////////////////////////////////////////////////////////////////////////
-// accumulator::statistics::empirical_distribution::ordered_sample.hpp //
+// ordered_sample.hpp //
// //
// Copyright 2010 Erwann Rogard. Distributed under the Boost //
// Software License, Version 1.0. (See accompanying file //
@@ -76,6 +76,7 @@
namespace tag
{
+
struct ordered_sample
: boost::accumulators::depends_on<>
{
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