1 #ifndef _theplu_yat_statistics_kolmogorov_smirnov_
2 #define _theplu_yat_statistics_kolmogorov_smirnov_
26 #include <boost/concept_check.hpp>
34 namespace statistics {
60 Element(
double x,
bool class_label,
double w=1.0);
91 void add(
double value,
bool class_label,
double weight=1.0);
106 template <
typename ForwardIterator>
107 void add(ForwardIterator first, ForwardIterator last);
135 double p_value(
size_t perm)
const;
145 void remove(
double value,
bool class_label,
double weight=1.0);
158 double score(
void)
const;
182 void scores(std::vector<double>&)
const;
185 template <
typename ForwardIterator>
186 void add_sum_w(ForwardIterator first, ForwardIterator last);
188 mutable bool cached_;
189 mutable double score_;
190 typedef std::multiset<Element> data_w;
212 template <
typename ForwardIterator>
215 BOOST_CONCEPT_ASSERT((boost::ForwardIterator<ForwardIterator>));
216 typedef typename std::iterator_traits<ForwardIterator>::reference ref;
217 BOOST_CONCEPT_ASSERT((boost::Convertible<ref, KolmogorovSmirnov::Element>));
218 ForwardIterator iter(first);
219 typename data_w::const_iterator hint(data_.begin());
220 for ( ; iter!=last; ++iter)
222 hint = data_.insert(hint, *iter);
223 add_sum_w(first, last);
228 template <
typename ForwardIterator>
229 void KolmogorovSmirnov::add_sum_w(ForwardIterator first,
230 ForwardIterator last)
232 while (first!=last) {
234 sum_w1_ += (*first).weight;
236 sum_w2_ += (*first).weight;