analistica/ex-1/bootstrap.h

83 lines
2.1 KiB
C
Raw Permalink Normal View History

#include <gsl/gsl_rng.h>
2020-04-04 19:09:21 +02:00
#pragma once
/* A pair structure that represent
* a value with an uncertainty
*/
typedef struct {
double n; // nominal value
double s; // uncertainty
} uncert;
2020-04-04 19:09:21 +02:00
/* Function that compare doubles for sorting:
* x > y 1
* x == y 0
* x < y -1
*/
int cmp_double (const void *xp, const void *yp);
/* 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
2020-04-04 19:09:21 +02:00
* sdtdev of the medians computed on each sample.
*/
uncert bootstrap_median(
const gsl_rng *r,
double *sample, size_t n,
2020-06-08 00:43:06 +02:00
size_t boots);
2020-04-04 19:09:21 +02:00
/* Computes an approximation to the asymptotic mode
* and its standard deviation by bootstrapping (ie
* repeated resampling) the original `sample`, `boots`
* times.
*
* The functions returns an `uncert` pair of mean and
* stddev of the modes computed on each sample.
*/
uncert bootstrap_mode(
const gsl_rng *r,
double *sample, size_t n,
2020-06-08 00:43:06 +02:00
size_t boots);
/* Computes an approximation to the asymptotic fwhm
* and its standard deviation by bootstrapping (ie
* repeated resampling) the original `sample`, `boots`
* times.
*
* `min,max` are the bounds of interval that is
* expected to contain the mode of the sample.
*
* The functions returns an `uncert` pair of mean and
* stddev of the fwhms computed on each sample.
*/
uncert bootstrap_fwhm(
const gsl_rng *r,
double min, double max,
double *sample, size_t n,
2020-06-08 00:43:06 +02:00
size_t boots);
/* Computes an approximation to the asymptotic right
* tail-index and its standard deviation by bootstrapping
* (ie repeated resampling) the original `sample`, `boots`
* times. The tail-index is estimated by the Hill estimator,
* hence the name of the function. See `hill_estimator()`
* for the parameter `t` meaning.
*
* The functions returns an `uncert` pair of mean and
* stddev of the modes computed on each sample.
*/
uncert bootstrap_hill(
const gsl_rng *r,
double t,
double *sample, size_t n,
size_t boots);