AntiMicroX
Loading...
Searching...
No Matches
statisticsestimator.h
Go to the documentation of this file.
1/* antimicrox Gamepad to KB+M event mapper
2 * Copyright (C) 2022 Max Maisel <max.maisel@posteo.de>
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17#pragma once
18
19#include <cstddef>
20
26{
27 public:
29
30 void reset();
31 void process(double x);
32
37 inline size_t getCount() const { return m_count; }
42 inline double getMean() const { return m_mean; }
43 double calculateVariance() const;
44 double calculateRelativeErrorSq() const;
45
46 private:
47 double m_mean;
48 double m_var;
49 size_t m_count;
50};
Estimates mean of a data stream using Welford's algorithm and calculates statistic properties.
Definition statisticsestimator.h:26
double getMean() const
Gets the mean of processed samples.
Definition statisticsestimator.h:42
double calculateRelativeErrorSq() const
Calculates the squared relative three sigma error range, i.e. the squared estimation accuracy in perc...
Definition statisticsestimator.cpp:58
void process(double x)
Processes a new sample of the current data stream and updates internal intermediate values.
Definition statisticsestimator.cpp:36
size_t m_count
Definition statisticsestimator.h:49
double calculateVariance() const
Calculates the sample variance of the processed data stream from internal intermediate values.
Definition statisticsestimator.cpp:50
size_t getCount() const
Gets the amount of processed samples.
Definition statisticsestimator.h:37
double m_mean
Definition statisticsestimator.h:47
void reset()
Resets the StatisticsEstimator so that it is ready to process a new data stream.
Definition statisticsestimator.cpp:25
StatisticsEstimator()
Definition statisticsestimator.cpp:20
double m_var
Definition statisticsestimator.h:48