diff --git a/ex-1/bootstrap.c b/ex-1/bootstrap.c index 3046015..d3eddb7 100644 --- a/ex-1/bootstrap.c +++ b/ex-1/bootstrap.c @@ -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