10#ifndef INFUSE_SDK_INCLUDE_INFUSE_MATH_STATISTICS_H_
11#define INFUSE_SDK_INCLUDE_INFUSE_MATH_STATISTICS_H_
53 memset(state, 0x00,
sizeof(*state));
78 return (
float)state->
m + ((float)state->
p / state->
n);
96 return (
float)state->
v + ((float)state->
w / (float)(state->
n - 1)) -
97 (state->
n * mean_error * mean_error / (state->
n - 1));
138 return state->
v + (state->
w / (state->
n - 1));
static int32_t statistics_mean_rough(const struct statistics_state *state)
Compute the rough mean of the statistics object.
Definition statistics.h:113
static float statistics_mean(const struct statistics_state *state)
Compute the mean of the statistics object.
Definition statistics.h:71
static uint64_t statistics_variance_rough(const struct statistics_state *state)
Compute the rough variance of the statistics object.
Definition statistics.h:133
void statistics_update(struct statistics_state *state, int32_t value)
Update the statistics object with a new sample.
static void statistics_reset(struct statistics_state *state)
Reset statistics object.
Definition statistics.h:51
static float statistics_variance(const struct statistics_state *state)
Compute the variance of the statistics object.
Definition statistics.h:88
Running statistics state.
Definition statistics.h:33
int64_t v
Variance approximation.
Definition statistics.h:35
uint32_t n
Sequence count.
Definition statistics.h:43
int32_t m
Mean approximation.
Definition statistics.h:39
int64_t w
Variance correction factor.
Definition statistics.h:37
int32_t p
Mean fractional accumulation.
Definition statistics.h:41