Infuse-IoT SDK API 0.0.1
A Scalable Open Source RTOS
|
Running statistics API . More...
Data Structures | |
struct | statistics_state |
Functions | |
static void | statistics_reset (struct statistics_state *state) |
Reset statistics object. | |
void | statistics_update (struct statistics_state *state, int32_t value) |
Update the statistics object with a new sample. | |
static float | statistics_mean (const struct statistics_state *state) |
Compute the mean of the statistics object. | |
static float | statistics_variance (const struct statistics_state *state) |
Compute the variance of the statistics object. | |
static int32_t | statistics_mean_rough (const struct statistics_state *state) |
Compute the rough mean of the statistics object. | |
static uint64_t | statistics_variance_rough (const struct statistics_state *state) |
Compute the rough variance of the statistics object. | |
Running statistics API .
This API is a C implementation of the following paper, which is itself inspired by the well known Welford's algorithm: https://sfat.massey.ac.nz/research/centres/crisp/pdfs/2013_IVCNZ_214.pdf
|
inlinestatic |
#include <infuse/math/statistics.h>
Compute the mean of the statistics object.
state | Statistics state object |
|
inlinestatic |
#include <infuse/math/statistics.h>
Compute the rough mean of the statistics object.
The computed value is "rough" in the sense that it does not attempt to round to the nearest whole number, and merely takes the integer portion.
Tests validate that this value is within 1.0f of the value returned by statistics_mean.
state | Statistics state object |
|
inlinestatic |
#include <infuse/math/statistics.h>
Reset statistics object.
state | Statistics state object to reset |
void statistics_update | ( | struct statistics_state * | state, |
int32_t | value ) |
#include <infuse/math/statistics.h>
Update the statistics object with a new sample.
state | Statistics state object |
value | New value to feed into state |
|
inlinestatic |
#include <infuse/math/statistics.h>
Compute the variance of the statistics object.
state | Statistics state object |
|
inlinestatic |
#include <infuse/math/statistics.h>
Compute the rough variance of the statistics object.
The computed value is "rough" in the sense that it does not attempt to round to the nearest whole number, and merely takes the integer portion. It also does not take into account the difference between state->m
and the true mean, as described in the paper.
Tests validate that this value is within 1.0f or 2% of the value returned by statistics_variance, whichever is less accurate.
state | Statistics state object |