blob: a35d1e2047bf77577d89e9ae32b6bc3f2e3388b1 (
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
|
#include "statistics.h"
// run this at each step to compute the running average
double average_step(
// the value at the step
double val,
// the average computed so far
double avg,
uint64_t t,
uint64_t starting_time,
uint64_t print_freq,
uint64_t first_box
){
// running average
// reset averages
if(t % print_freq == 1){
return(0);
}
// compute average
// different computationin first box if starting_time is not a multiple of print_freq
if(t < starting_time + first_box){
return(avg+val/first_box);
} else {
return(avg+val/print_freq);
}
}
|