1 #ifndef _theplu_yat_normalizer_z_score_
2 #define _theplu_yat_normalizer_z_score_
28 #include "yat/statistics/Averager.h"
29 #include "yat/statistics/AveragerWeighted.h"
31 #include "yat/utility/iterator_traits.h"
33 #include <boost/concept_check.hpp>
37 namespace normalizer {
62 template<
class ForwardIter1,
class ForwardIter2>
64 ForwardIter2 result)
const
67 normalize(first, last, result, tag);
71 template<
class ForwardIterator,
class OutputIterator>
72 void normalize(ForwardIterator first, ForwardIterator last,
73 OutputIterator result,
78 BOOST_CONCEPT_ASSERT((boost::ForwardIterator<ForwardIterator>));
79 BOOST_CONCEPT_ASSERT((boost::OutputIterator<OutputIterator, double>));
85 *result = (*first - m) / std;
91 template<
class ForwardIter1,
class ForwardIter2>
92 void normalize(ForwardIter1 first, ForwardIter1 last, ForwardIter2 result,
93 utility::weighted_iterator_tag tag)
const
97 BOOST_CONCEPT_ASSERT((boost::ForwardIterator<ForwardIter1>));
98 BOOST_CONCEPT_ASSERT((boost::Mutable_ForwardIterator<ForwardIter2>));
99 detail::copy_weight_if_weighted(first, last, result);
100 statistics::AveragerWeighted a;
103 double std = a.std();
104 utility::iterator_traits<ForwardIter1> in_trait;
105 utility::iterator_traits<ForwardIter2> out_trait;
106 while (first!=last) {
107 out_trait.data(result) = (in_trait.data(first) - m) / std;