31 lines
632 B
C
31 lines
632 B
C
#ifndef ONLINEMEAN_H_
|
|
#define ONLINEMEAN_H_
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Set to 1 to return unbiased (sample) variance
|
|
* rather than a population variance */
|
|
#define UNBIASED_ESTIMATOR 0
|
|
|
|
#include <stdint.h>
|
|
|
|
typedef struct OnlineMean {
|
|
float mean;
|
|
float varsum; // variance sum
|
|
uint32_t count;
|
|
} OnlineMean_t;
|
|
|
|
void OnlineMean_Init(OnlineMean_t *oMean);
|
|
void OnlineMean_Update(OnlineMean_t *oMean, float newValue);
|
|
float OnlineMean_GetMean(OnlineMean_t *oMean);
|
|
float OnlineMean_GetStd(OnlineMean_t *oMean);
|
|
void OnlineMean_Reset(OnlineMean_t *oMean);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* ONLINEMEAN_H_ */
|