# (lispkit math stats)

Library `(lispkit math stats)` implements statistical utility functions. The functions compute summary values for collections of samples, and functions for managing sequences of samples. Most of the functions accept a list of real numbers corresponding to sample values.

***

**(mode&#x20;*****xs*****)** <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Computes the mode of a set of numbers *xs*. The mode is the value that appears most often in *xs*. *xs* is a proper list of numeric values. `=` is used as the equality operator.

**(mean&#x20;*****xs*****)** <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Computes the arithmetic mean of a set of numbers *xs*. *xs* is a proper list of numeric values.

**(range&#x20;*****xs*****)** <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Computes the range of a set of numbers *xs*, i.e. the difference between the largest and the smallest value. *xs* is a proper list of numeric values which are ordered using the `<` relation.

**(variance&#x20;*****xs*****)** <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">\
\&#xNAN;**(variance&#x20;*****xs bias*****)**

Computes the variance for a set of numbers *xs*, optionally applying bias correction. *xs* is a proper list of numeric values. Bias correction gets enabled by setting *bias* to `#t`. Alternatively, it is possible to provide a positive integer, which is used instead of the number of elements in *xs*.

**(stddev&#x20;*****xs*****)** <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">\
\&#xNAN;**(stddev&#x20;*****xs bias*****)**

Computes the standard deviation for a set of numbers *xs*, optionally applying bias correction. *xs* is a proper list of numeric values. Bias correction gets enabled by setting *bias* to `#t`. Alternatively, it is possible to provide a positive integer, which is used instead of the number of elements in *xs*.

**(skewness&#x20;*****xs*****)** <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">\
\&#xNAN;**(skewness&#x20;*****xs bias*****)**

Computes the skewness for a set of numbers *xs*, optionally applying bias correction. *xs* is a proper list of numeric values. Bias correction gets enabled by setting *bias* to `#t`. Alternatively, it is possible to provide a positive integer, which is used instead of the number of elements in *xs*.

**(kurtosis&#x20;*****xs*****)** <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">\
\&#xNAN;**(kurtosis&#x20;*****xs bias*****)**

Computes the kurtosis for a set of numbers *xs*, optionally applying bias correction. *xs* is a proper list of numeric values. Bias correction gets enabled by setting *bias* to `#t`. Alternatively, it is possible to provide a positive integer, which is used instead of the number of elements in *xs*.

**(absdev&#x20;*****xs*****)** <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Computes the average absolute difference between the numbers in list *xs* and `(median xs)`.

**(quantile&#x20;*****xs p*****)** <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Computes the p-quantile for a set of numbers *xs* (also known as the *inverse cumulative distribution*). *p* is a real number between 0 and 1.0. For instance, the 0.5-quantile corresponds to the median.

**(percentile&#x20;*****xs pct*****)** <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Computes the percentile for a set of numbers *xs* and a given percentage *pct*. *pct* is a number between 0 and 100. For instance, the 90th percentile corresponds to the 0.9-quantile.

**(median&#x20;*****xs*****)** <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Computes the median for a set of numbers *xs*.

**(interquartile-range&#x20;*****xs*****)** <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Returns the interquartile range for a given set of numbers *xs*. *xs* is a proper list of numeric values. The interquartile range is the difference between the 0.75-quantile and the 0.25-quantile.

**(five-number-summary&#x20;*****xs*****)** <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">

Returns a list of 5 statistics describing the set of numbers *xs*: the minimum value, the lower quartile, the median, the upper quartile, and the maximum value.

**(covariance&#x20;*****xs ys*****)** <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">\
\&#xNAN;**(covariance&#x20;*****xs ys bias*****)**

Computes the covariance of two sets of numbers *xs* and *ys*. Both *xs* and *ys* are proper lists of numbers. Bias correction can be enabled by setting *bias* to `#t`. Alternatively, it is possible to provide a positive integer, which is used instead of the number of elements in *xs*.

**(correlation&#x20;*****xs ys*****)** <img src="https://1467949168-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fna2foeoaXHYkSD3fhs0t%2Fuploads%2Fgit-blob-d20368c588cfbb523beb2fae4f8be0f8ef011884%2Fproc.png?alt=media" alt="" data-size="line">\
\&#xNAN;**(correlation&#x20;*****xs ys bias*****)**

Computes the correlation of two sets of numbers *xs* and *ys* in form of the *Pearson product-moment correlation coefficient*. Both *xs* and *ys* are proper lists of numbers. Bias correction can be enabled by setting *bias* to `#t`. Alternatively, it is possible to provide a positive integer, which is used instead of the number of elements in *xs*.
