Mercurial > hg > fxanalyse
comparison stat.c @ 144:be87c8e78266
Code cleanup
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Wed, 22 Jan 2014 14:45:24 +0100 |
parents | e04123ab79ef |
children |
comparison
equal
deleted
inserted
replaced
143:09a4548e1436 | 144:be87c8e78266 |
---|---|
11 | 11 |
12 | 12 |
13 void stat_accumulate(struct stat *s, double value) | 13 void stat_accumulate(struct stat *s, double value) |
14 { | 14 { |
15 s->samples += 1; | 15 s->samples += 1; |
16 | |
17 if (s->samples > 1) | 16 if (s->samples > 1) |
18 s->slope = (s->slope * (s->samples - 2) + 6 * (value - s->mean) / s->samples) / (s->samples + 1); | 17 s->slope = (s->slope * (s->samples - 2) + 6 * (value - s->mean) / s->samples) / (s->samples + 1); |
19 | |
20 s->mean = ((s->samples - 1) * s->mean + value) / s->samples; | 18 s->mean = ((s->samples - 1) * s->mean + value) / s->samples; |
21 | |
22 s->previous = value; | 19 s->previous = value; |
23 } | 20 } |
24 | 21 |
25 | 22 |
26 void rollmean_zero(struct rollmean *s) | 23 void rollmean_zero(struct rollmean *s) |