The GSL-RUNNING-STATISTICS module ********************************* .. current-library:: dylan-gsl .. current-module:: gsl-running-statistics 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: .. code-block:: dylan let data = #[17.2d0, 18.1d0, 16.5d0, 18.3d0, 12.6d0]; let rstat = make(); // 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 ---------------------------- .. class:: :supers: :drm:`` :slot rstat-min: An instance of :class:``. Minimal value seen so far. :slot rstat-max: An instance of :class:``. Maximal value seen so far. :slot rstat-mean: An instance of :class:``. Mean of the values seen so far. :slot rstat-variance: An instance of :class:``. Variance of the values seen so far. :slot rstat-sd: An instance of :class:``. Standard deviation of the values seen so far. :slot rstat-sd-mean: An instance of :class:``. Standard deviation of the mean of the values seen so far. :slot rstat-rms: An instance of :class:``. Root mean square of the values seen so far. :slot rstat-skew: An instance of :class:``. Skewness of the values seen so far. :slot rstat-kurtosis: An instance of :class:``. Kurtosis of the values seen so far. :slot rstat-median: An instance of :class:``. Median of the values seen so far. :slot rstat-norm: An instance of :class:``. Norm of the values seen so far. .. method:: size :specializer: :signature: size (rstat) => (n :: ) :parameter rstat: An instance of :class:``. Adding values to the accumulator -------------------------------- .. generic-function:: rstat-add! :signature: rstat-add! (rstat, x) => () :parameter rstat: An instance of :class:``. :parameter x: A :drm:``. .. method:: rstat-add! :specializer: :signature: rstat-add! (rstat, x) => () :parameter rstat: An instance of :class:``. :parameter x: A :class:``. .. method:: rstat-add! :specializer: :signature: rstat-add! (rstat, x) => () :parameter rstat: An instance of :class:``. :parameter x: A :drm:``. Resetting the accumulator ------------------------- .. function:: rstat-reset! :signature: rstat-reset! (rstat) => () :parameter rstat: An instance of :class:``. Quantiles ========= .. class:: :supers: :drm:`` :slot quantile-rstat-p: An instance of :class:``. The probability of the quantile. .. generic-function:: quantile-rstat-add! :signature: quantile-rstat-add! (quantile-rstat, x) => () :parameter quantile-rstat: An instance of :class:``. :parameter x: A :drm:``. .. method:: quantile-rstat-add! :specializer: :signature: quantile-rstat-add! (quantile-rstat, x) => () :parameter quantile-rstat: An instance of :class:``. :parameter x: A :class:``. .. method:: quantile-rstat-add! :specializer: :signature: quantile-rstat-add! (quantile-rstat, x) => () :parameter quantile-rstat: An instance of :class:``. :parameter x: A :drm:``. .. function:: quantile-rstat-get :signature: quantile-rstat-get (quantile-rstat) => (quantile :: ) :parameter quantile-rstat: An instance of :class:``. .. function:: quantile-rstat-reset! :signature: quantile-rstat-reset! (quantile-rstat) => () :parameter quantile-rstat: An instance of :class:``.