analistica/ex-1/bootstrap.h

25 lines
557 B
C
Raw Normal View History

#include <gsl/gsl_rng.h>
/* A pair structure that represent
* a value with an uncertainty
*/
typedef struct {
double n; // nominal value
double s; // uncertainty
} uncert;
/* Computes an approximation to the asymptotic median
* and its standard deviation by bootstrapping (ie
* repeated resampling) the original `sample`, `boots`
* times.
*
* The functions returns an `uncert` pair of mean and
* stdev of the medians computed on each sample.
*/
uncert bootstrap_median(
const gsl_rng *r,
double *sample, size_t n,
int boots);