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/concept_check.h" 32 #include "yat/utility/iterator_traits.h" 34 #include <boost/concept_check.hpp> 38 namespace normalizer {
85 template<
class InputIterator,
class OutputIterator>
87 OutputIterator result)
const 94 normalize(first, last, result, tag);
101 template<
class ForwardIterator,
class OutputIterator>
102 void normalize(ForwardIterator first, ForwardIterator last,
103 OutputIterator result,
109 BOOST_CONCEPT_ASSERT((boost_concepts::ForwardTraversal<ForwardIterator>));
111 BOOST_CONCEPT_ASSERT((boost_concepts::WritableIterator<OutputIterator>));
116 double factor = 1.0 / (a.
std() * k_);
117 while (first!=last) {
118 *result = (*first - m) * factor;
124 template<
class ForwardIterator,
class OutputIterator>
125 void normalize(ForwardIterator first, ForwardIterator last,
126 OutputIterator result,
127 utility::weighted_iterator_tag tag)
const 132 BOOST_CONCEPT_ASSERT((boost_concepts::ForwardTraversal<ForwardIterator>));
134 BOOST_CONCEPT_ASSERT((boost_concepts::WritableIterator<OutputIterator>));
136 BOOST_CONCEPT_ASSERT((boost_concepts::ForwardTraversal<OutputIterator>));
137 detail::copy_weight_if_weighted(first, last, result);
138 statistics::AveragerWeighted a;
141 double factor = 1.0 / (a.std() * k_);
142 utility::iterator_traits<ForwardIterator> in_trait;
143 utility::iterator_traits<OutputIterator> out_trait;
144 while (first!=last) {
145 out_trait.data(result) = (in_trait.data(first) - m) * factor;
Zero mean and unity variance.
Definition: Zscore.h:57
Concept check for Data Iterator.
Definition: concept_check.h:240
double std(void) const
The standard deviation is defined as the square root of the variance.
Definition: averager_base.h:206
Class to calculate simple (first and second moments) averages.
Definition: Averager.h:46
The Department of Theoretical Physics namespace as we define it.
Definition: iterator_traits.h:47
void operator()(InputIterator first, InputIterator last, OutputIterator result) const
Definition: Zscore.h:86
double mean(void) const
mean
Definition: averager_base.h:97
detail::unweighted_type_and< w_type1, w_type2 >::type type
return unweighted if both are unweighted
Definition: iterator_traits.h:165