summaryrefslogtreecommitdiff
path: root/decoders/session_flags/onlinemean.h
blob: 6cb5c959b7d52198946648af257a57e2d584ba12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#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_ */