### 22.4 Quantiles

The functions in this section estimate quantiles dynamically without storing the entire dataset, using the algorithm of Jain and Chlamtec, 1985. Only five points (markers) are stored which represent the minimum and maximum of the data, as well as current estimates of the p/2-, p-, and (1+p)/2-quantiles. Each time a new data point is added, the marker positions and heights are updated.

Function: gsl_rstat_quantile_workspace * gsl_rstat_quantile_alloc (const double p)

  This function allocates a workspace for the dynamic estimation of p-quantiles, where p is between 0 and 1. The median corresponds to p = 0.5. The size of the workspace is O(1).

Function: void gsl_rstat_quantile_free (gsl_rstat_quantile_workspace * w)

  This function frees the memory associated with the workspace w.

Function: int gsl_rstat_quantile_reset (gsl_rstat_quantile_workspace * w)

  This function resets the workspace w to its initial state, so it can begin working on a new set of data.

Function: int gsl_rstat_quantile_add (const double x, gsl_rstat_quantile_workspace * w)

  This function updates the estimate of the p-quantile with the new data point x.

Function: double gsl_rstat_quantile_get (gsl_rstat_quantile_workspace * w)

  This function returns the current estimate of the p-quantile.