RobTillaart / Statistic

Statistic library for Arduino includes sum, average, variance and std deviation
MIT License
27 stars 11 forks source link
arduino statistics

Arduino CI Arduino-lint JSON check GitHub issues

License: MIT GitHub release PlatformIO Registry

Statistic

Header-only statistic library for Arduino includes sum, average, variance and standard deviation.

The statistic::Statistic<T, C, bool _useStdDev> class template accepts 3 arguments:

To maintain backwards compatibility with API <= 0.4.4, the Statistic class implementation has been moved to the statistic namespace and a typedef statistic::Statistic<float, uint32_t, true> Statistic type definition has been created at global scope.

The useStdDev boolean was moved from a run-time to a compile-time option for two reasons. First, the compile-time option allows the optimizer to eliminate dead code (calculating standard deviation and variances) for a slightly smaller code size. Second, it was observed in uses of the library that the useStdDev boolean was set once in the class constructor and was never modified at run-time.

Description

The statistic library is made to get basic statistical information from a one dimensional set of data, e.g. a stream of values of a sensor.

The stability of the formulas is improved by the help of Gil Ross (Thanks!).

The template version (1.0.0) is created by Glen Cornell (Thanks!).

Related

Interface

#include "Statistic.h"

Constructor

Core

These three functions only work if useStdDev == true (in the template).

Deprecated methods

Range() and middle()

Range() and middle() are fast functions with limited statistical value. Still they have their uses.

Given enough samples (e.g. 100+) and a normal distribution of the samples the range() is expected to be 3 to 4 times the pop_stdev(). If the range is larger than 4 standard deviations one might have added one or more outliers.

Given enough samples (e.g. 100+) and a normal distribution, the middle() and average() are expected to be close to each other. Note: outliers can disrupt the middle(), Several non-normal distributions do too.

Operational

See examples.

Faq

See https://github.com/RobTillaart/Statistic/blob/master/FAQ.md

Future

Must

Should

Could

Wont

Support

If you appreciate my libraries, you can support the development and maintenance. Improve the quality of the libraries by providing issues and Pull Requests, or donate through PayPal or GitHub sponsors.

Thank you,