herald  2.0.0
distribution.h
1 // Copyright 2021 Herald Project Contributors
2 // SPDX-License-Identifier: Apache-2.0
3 //
4 
5 #ifndef HERALD_DISTRIBUTION_H
6 #define HERALD_DISTRIBUTION_H
7 
8 #include <cstddef>
9 #include <string>
10 
11 namespace herald {
12 namespace datatype {
13 
16 class Distribution {
17 public:
19  Distribution() noexcept;
21  Distribution(double x, std::size_t frequency) noexcept;
23  ~Distribution() noexcept = default;
24 
26  void add(double x) noexcept;
28  void add(double x, std::size_t frequency) noexcept;
30  void add(const Distribution& other) noexcept;
31 
33  const std::size_t count() const noexcept;
35  const double mean() const noexcept;
37  const double variance() const noexcept;
39  const double standardDeviation() const noexcept;
41  const double min() const noexcept;
43  const double max() const noexcept;
44 
46  operator std::string() const noexcept;
47 
49  void reset() noexcept;
50 
51 private:
53  std::size_t n;
55  double m1;
57  double m2;
59  double minimum;
61  double maximum;
62 };
63 
64 }
65 }
66 
67 #endif
Definition: distribution.h:16
const std::size_t count() const noexcept
return the count
const double min() const noexcept
Return the minimum recorded value.
const double standardDeviation() const noexcept
Return the standard deviation.
const double variance() const noexcept
return the variance
Distribution() noexcept
Initialise an empty distribution.
void add(double x) noexcept
Add a single occurence of a value.
void reset() noexcept
Reset this instance to its initial state.
const double max() const noexcept
Return the maximum recorded value.
const double mean() const noexcept
return the mean
Acts as a non-global memory arena for arbitrary classes.
Definition: aggregates.h:15
Definition: data.h:562