Infuse-IoT SDK API 0.0.1
A Scalable Open Source RTOS
Loading...
Searching...
No Matches
Infuse-IoT running statistics APIs

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.
 

Detailed Description

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

Function Documentation

◆ statistics_mean()

static float statistics_mean ( const struct statistics_state * state)
inlinestatic

#include <infuse/math/statistics.h>

Compute the mean of the statistics object.

Parameters
stateStatistics state object
Returns
float Mean of samples

◆ statistics_mean_rough()

static int32_t statistics_mean_rough ( const struct statistics_state * state)
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.

Parameters
stateStatistics state object
Returns
uint32_t Approximate mean of samples

◆ statistics_reset()

static void statistics_reset ( struct statistics_state * state)
inlinestatic

#include <infuse/math/statistics.h>

Reset statistics object.

Parameters
stateStatistics state object to reset

◆ statistics_update()

void statistics_update ( struct statistics_state * state,
int32_t value )

#include <infuse/math/statistics.h>

Update the statistics object with a new sample.

Parameters
stateStatistics state object
valueNew value to feed into state

◆ statistics_variance()

static float statistics_variance ( const struct statistics_state * state)
inlinestatic

#include <infuse/math/statistics.h>

Compute the variance of the statistics object.

Parameters
stateStatistics state object
Returns
float Variance of samples

◆ statistics_variance_rough()

static uint64_t statistics_variance_rough ( const struct statistics_state * state)
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.

Parameters
stateStatistics state object
Returns
uint64_t Approximate variance of samples