ex-1: compute exact median
The approximation of the running statistics isn't accurate enough.
This commit is contained in:
parent
e02e4a9557
commit
602e08b2a2
@ -179,6 +179,7 @@ uncert bootstrap_median(
|
||||
gsl_rstat_workspace* w = gsl_rstat_alloc();
|
||||
|
||||
double *values = calloc(boots, sizeof(double));
|
||||
double *resample = calloc(n, sizeof(double));
|
||||
|
||||
for (size_t i = 0; i < boots; i++) {
|
||||
/* The sampling is simply done by generating
|
||||
@ -186,9 +187,9 @@ uncert bootstrap_median(
|
||||
*/
|
||||
for (size_t j = 0; j < n; j++) {
|
||||
size_t choice = gsl_rng_uniform_int(r, n);
|
||||
gsl_rstat_add(sample[choice], w);
|
||||
resample[j] = sample[choice];
|
||||
}
|
||||
values[i] = gsl_rstat_median(w);
|
||||
values[i] = gsl_stats_median(resample, 1, n);
|
||||
}
|
||||
|
||||
/* Compute mean and stdev of the medians
|
||||
|
Loading…
Reference in New Issue
Block a user