Maintains running statistics for a stream of values using Welford's online algorithm.
More...
#include <fx_stats_util.h>
|
| void | add (double x) |
| | Adds a new value to the statistics. More...
|
| |
| bool | ready () const |
| | Checks if the statistics are ready (i.e., more than one value has been processed). More...
|
| |
| double | sigma () const |
| | Returns the sample standard deviation of the values. More...
|
| |
| void | clear () |
| | Resets the statistics to their initial state. More...
|
| |
|
| uint64_t | count {0} |
| | Number of values processed so far. More...
|
| |
| double | mean {0.0} |
| | Current mean of the values. More...
|
| |
| double | m2 {0.0} |
| | Sum of squared deviations from the mean. More...
|
| |
Maintains running statistics for a stream of values using Welford's online algorithm.
This struct provides a way to calculate the mean and variance of a dataset without storing the entire dataset in memory. It is suitable for large or streaming datasets. The statistics are updated incrementally as new values are added using the add method.
◆ add()
| void Welford_Stats::add |
( |
double |
x | ) |
|
|
inline |
Adds a new value to the statistics.
- Parameters
-
- Note
- add() updates running statistics online (count/mean/M2) one residual at a time, and sigma() returns the stddev when needed. This avoids having to store all residuals and then compute the stddev.
◆ clear()
| void Welford_Stats::clear |
( |
| ) |
|
|
inline |
Resets the statistics to their initial state.
◆ ready()
| bool Welford_Stats::ready |
( |
| ) |
const |
|
inline |
Checks if the statistics are ready (i.e., more than one value has been processed).
- Returns
- True if the statistics are ready, false otherwise.
◆ sigma()
| double Welford_Stats::sigma |
( |
| ) |
const |
|
inline |
Returns the sample standard deviation of the values.
- Returns
- The sample standard deviation.
◆ count
| uint64_t Welford_Stats::count {0} |
Number of values processed so far.
◆ m2
| double Welford_Stats::m2 {0.0} |
Sum of squared deviations from the mean.
◆ mean
| double Welford_Stats::mean {0.0} |
Current mean of the values.
The documentation for this struct was generated from the following file: