add socks_decoder, stratum_decoder and session_flags

This commit is contained in:
root
2024-09-03 07:01:58 +00:00
parent a8206cffc0
commit 6f1ac6b36b
160 changed files with 11861 additions and 1 deletions

View File

@@ -0,0 +1,37 @@
#include <math.h>
#include "onlinemean.h"
void OnlineMean_Init(OnlineMean_t *oMean) {
OnlineMean_Reset(oMean);
}
void OnlineMean_Update(OnlineMean_t *oMean, float newValue) {
oMean->count++;
if (oMean->count > 1) {
float delta = newValue - oMean->mean;
oMean->mean += delta / oMean->count;
oMean->varsum += delta * (newValue - oMean->mean);
} else {
oMean->mean = newValue;
}
}
float OnlineMean_GetMean(OnlineMean_t *oMean) {
return oMean->mean;
}
float OnlineMean_GetStd(OnlineMean_t *oMean) {
if (oMean->count == 0)
return 0;
#if UNBIASED_ESTIMATOR
return sqrt(oMean->varsum / (oMean->count - 1));
#else
return sqrt(oMean->varsum / oMean->count);
#endif /* UNBIASED_ESTIMATOR */
}
void OnlineMean_Reset(OnlineMean_t *oMean) {
oMean->count = 0;
oMean->mean = 0.f;
oMean->varsum = 0.f;
}