The GSL-RUNNING-STATISTICS module¶
The gsl-running-statistics module provides routines for computing running
statistics. These routines process data in a single pass, making them
suitable for large datasets where storing all points in memory is impractical.
The module supports exact calculations for mean, variance, and higher-order
moments, as well as approximate calculations for medians and quantiles.
Statistical summary¶
Here is a basic example of how to use the statistical functions:
let data = #[17.2d0, 18.1d0, 16.5d0, 18.3d0, 12.6d0];
let rstat = make(<rstat>);
// for (x in data) rstat-add!(rstat, x) end
rstat-add!(rstat, data);
format-out("The dataset is %=\n", data);
format-out("The sample mean is %=\n", rstat.rstat-mean);
format-out("The estimated variance is %=\n", rstat.rstat-variance);
format-out("The largest value is %=\n", rstat.rstat-max);
format-out("The smallest value is %=\n", rstat.rstat-min);
format-out("The median is %=\n", rstat.rstat-median);
format-out("The standard deviation is %=\n", rstat.rstat-sd);
format-out("The root mean square is %=\n", rstat.rstat-rms);
format-out("The standard devation of the mean is %=\n", rstat.rstat-sd-mean);
format-out("The skew is %=\n", rstat.rstat-skew);
format-out("The kurtosis %=\n", rstat.rstat-kurtosis);
format-out("There are %d items in the accumulator\n", rstat.rstat-n);
rstat.rstat-reset!;
format-out("There are %d items in the accumulator\n", rstat.size);
Class and current statistics¶
- <rstat> Class¶
- Superclasses:
- Slots:
rstat-min – An instance of
<double-float>. Minimal value seen so far.rstat-max – An instance of
<double-float>. Maximal value seen so far.rstat-mean – An instance of
<double-float>. Mean of the values seen so far.rstat-variance – An instance of
<double-float>. Variance of the values seen so far.rstat-sd – An instance of
<double-float>. Standard deviation of the values seen so far.rstat-sd-mean – An instance of
<double-float>. Standard deviation of the mean of the values seen so far.rstat-rms – An instance of
<double-float>. Root mean square of the values seen so far.rstat-skew – An instance of
<double-float>. Skewness of the values seen so far.rstat-kurtosis – An instance of
<double-float>. Kurtosis of the values seen so far.rstat-median – An instance of
<double-float>. Median of the values seen so far.rstat-norm – An instance of
<double-float>. Norm of the values seen so far.
Adding values to the accumulator¶
- rstat-add! Generic function¶
- rstat-add!(<double-float>) Method¶
- Signature:
rstat-add! (rstat, x) => ()
- Parameters:
rstat – An instance of
<rstat>.x – A
<double-float>.
- rstat-add!(<sequence>) Method¶
- Signature:
rstat-add! (rstat, x) => ()
- Parameters:
rstat – An instance of
<rstat>.x – A
<sequence>.
Resetting the accumulator¶
Quantiles¶
- <quantile-rstat> Class¶
- Superclasses:
- Slots:
quantile-rstat-p – An instance of
<double-float>. The probability of the quantile.
- quantile-rstat-add! Generic function¶
- Signature:
quantile-rstat-add! (quantile-rstat, x) => ()
- Parameters:
quantile-rstat – An instance of
<quantile-rstat>.x – A
<object>.
- quantile-rstat-add!(<double-float>) Method¶
- Signature:
quantile-rstat-add! (quantile-rstat, x) => ()
- Parameters:
quantile-rstat – An instance of
<quantile-rstat>.x – A
<double-float>.
- quantile-rstat-add!(<sequence>) Method¶
- Signature:
quantile-rstat-add! (quantile-rstat, x) => ()
- Parameters:
quantile-rstat – An instance of
<quantile-rstat>.x – A
<sequence>.
- quantile-rstat-get Function¶
- Signature:
quantile-rstat-get (quantile-rstat) => (quantile :: <double-float>)
- Parameters:
quantile-rstat – An instance of
<quantile-rstat>.
- quantile-rstat-reset! Function¶
- Signature:
quantile-rstat-reset! (quantile-rstat) => ()
- Parameters:
quantile-rstat – An instance of
<quantile-rstat>.