1 #ifndef _theplu_yat_statistics_kolmogorov_smirnov_
2 #define _theplu_yat_statistics_kolmogorov_smirnov_
26 #include "yat/utility/concept_check.h"
28 #include <boost/concept_check.hpp>
29 #include <boost/iterator/iterator_concepts.hpp>
37 namespace statistics {
63 Element(
double x,
bool class_label,
double w=1.0);
94 void add(
double value,
bool class_label,
double weight=1.0);
112 template <
typename ForwardIterator>
113 void add(ForwardIterator first, ForwardIterator last);
141 double p_value(
size_t perm)
const;
151 void remove(
double value,
bool class_label,
double weight=1.0);
164 double score(
void)
const;
188 void scores(std::vector<double>&)
const;
191 template <
typename ForwardIterator>
192 void add_sum_w(ForwardIterator first, ForwardIterator last);
194 mutable bool cached_;
195 mutable double score_;
196 typedef std::multiset<Element> data_w;
218 template <
typename ForwardIterator>
221 BOOST_CONCEPT_ASSERT((boost_concepts::ForwardTraversal<ForwardIterator>));
222 BOOST_CONCEPT_ASSERT((boost_concepts::ReadableIterator<ForwardIterator>));
223 ForwardIterator iter(first);
224 typename data_w::const_iterator hint(data_.begin());
225 for ( ; iter!=last; ++iter)
227 hint = data_.insert(hint, *iter);
228 add_sum_w(first, last);
233 template <
typename ForwardIterator>
234 void KolmogorovSmirnov::add_sum_w(ForwardIterator first,
235 ForwardIterator last)
237 while (first!=last) {
239 sum_w1_ += (*first).weight;
241 sum_w2_ += (*first).weight;
Definition: KolmogorovSmirnov.h:53
void shuffle(void)
shuffle class labels
bool label
Definition: KolmogorovSmirnov.h:73
double signed_score(void) const
bool operator<(const Element &rhs) const
Element(void)
default constructor
Kolmogorov Smirnov Test.
Definition: KolmogorovSmirnov.h:42
void add(double value, bool class_label, double weight=1.0)
add a value
double weight
Definition: KolmogorovSmirnov.h:78
void reset(void)
resets everything to zero
KolmogorovSmirnov(void)
Constructor.
double value
data value
Definition: KolmogorovSmirnov.h:68
double score(void) const
Kolmogorov Smirnov statistic.
double p_value(void) const
Large-Sample Approximation.