Mercurial > hg > fxanalyse
annotate stat.c @ 141:e1dec4f11831
Plot user interface tweaks
author | Daniele Nicolodi <daniele.nicolodi@obspm.fr> |
---|---|
date | Wed, 22 Jan 2014 14:45:22 +0100 |
parents | e04123ab79ef |
children | be87c8e78266 |
rev | line source |
---|---|
139 | 1 #include <ansi_c.h> |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
2 #include "stat.h" |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
3 |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
4 void stat_zero(struct stat *s) |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
5 { |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
6 s->samples = 0; |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
7 s->mean = 0.0; |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
8 s->slope = 0.0; |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
9 s->previous = 0.0; |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
10 } |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
11 |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
12 |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
13 void stat_accumulate(struct stat *s, double value) |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
14 { |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
15 s->samples += 1; |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
16 |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
17 if (s->samples > 1) |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
18 s->slope = (s->slope * (s->samples - 2) + 6 * (value - s->mean) / s->samples) / (s->samples + 1); |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
19 |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
20 s->mean = ((s->samples - 1) * s->mean + value) / s->samples; |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
21 |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
22 s->previous = value; |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
23 } |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
24 |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
25 |
139 | 26 void rollmean_zero(struct rollmean *s) |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
27 { |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
28 s->nobs = 0; |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
29 s->mean = 0.0; |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
30 s->acc = 0.0; |
139 | 31 memset(s->prev, 0, sizeof(s->prev)); |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
32 } |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
33 |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
34 |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
35 void rollmean_accumulate(struct rollmean *s, double value) |
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
36 { |
139 | 37 s->acc = s->acc + value - s->prev[s->nobs % _ROLLMEAN_WLEN]; |
38 s->prev[s->nobs % _ROLLMEAN_WLEN] = value; | |
39 s->nobs++; | |
40 if (s->nobs < _ROLLMEAN_WLEN) | |
41 s->mean = s->acc / s->nobs; | |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
42 else |
139 | 43 s->mean = s->acc / _ROLLMEAN_WLEN; |
133
7540703b8473
Major code cleanup. Implement beatnote recentering.
Daniele Nicolodi <daniele.nicolodi@obspm.fr>
parents:
diff
changeset
|
44 } |