Vita
distribution.h
Go to the documentation of this file.
1
13#if !defined(VITA_DISTRIBUTION_H)
14#define VITA_DISTRIBUTION_H
15
16#include <cmath>
17#include <iomanip>
18#include <map>
19
20#include "kernel/log.h"
21#include "utility/utility.h"
22
23namespace vita
24{
29template<class T>
31{
32public:
34
35 void clear();
36
37 template<class U> void add(U);
38
39 std::uintmax_t count() const;
40 double entropy() const;
41 T max() const;
42 T mean() const;
43 T min() const;
44 const std::map<T, std::uintmax_t> &seen() const;
45 T standard_deviation() const;
46 T variance() const;
47
48 bool is_valid() const;
49
50public: // Serialization
51 bool load(std::istream &);
52 bool save(std::ostream &) const;
53
54private: // Private methods
55 void update_variance(T);
56
57private: // Private data members
58 std::map<T, std::uintmax_t> seen_;
59
60 T m2_;
61 T max_;
62 T mean_;
63 T min_;
64
65 std::uintmax_t count_;
66};
67
68#include "kernel/distribution.tcc"
69} // namespace vita
70
71#endif // Include guard
Simplifies the calculation of statistics regarding a sequence (mean, variance, standard deviation,...
Definition: distribution.h:31
The main namespace for the project.