# Module /statistics

Descriptive and rolling statistics: mean, weighted-mean, variance, standard deviation, change metrics, and moving averages.

```tangu
(use /statistics)
```

## Functions & symbols

### absolute-difference

`(absolute-difference x y)`

Computes the absolute magnitude of difference `|(x - y)|`.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `x` | `Any` | no | — |
| `y` | `Any` | no | — |

### compute-max

`(compute-max xs)`

Returns the maximum numeric element in `xs`.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `xs` | `Any` | no | — |

### compute-min

`(compute-min xs)`

Returns the minimum numeric element in `xs`.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `xs` | `Any` | no | — |

### compute-sum

`(compute-sum xs)`

Computes the floating-point sum of numeric sequence `xs`.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `xs` | `Any` | no | — |

### difference

`(difference x y)`

Computes the signed difference `(- x y)`.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `x` | `Any` | no | — |
| `y` | `Any` | no | — |

### mean

`(mean xs)`

Computes the arithmetic mean of numeric sequence `xs`.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `xs` | `Any` | no | — |

### mean-absolute-deviation

`(mean-absolute-deviation xs)`

Computes the mean absolute deviation (MAD) of numeric sequence `xs`.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `xs` | `Any` | no | — |

### population-standard-deviation

`(population-standard-deviation xs)`

Computes the population standard deviation (`sqrt(population-variance)`).

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `xs` | `Any` | no | — |

### population-variance

`(population-variance xs)`

Computes the population variance (`1/N` denominator) of numeric sequence `xs`.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `xs` | `Any` | no | — |

### relative-change

`(relative-change x x-ref)`

Computes the relative change `((x - x-ref) / |x-ref|)`.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `x` | `Any` | no | — |
| `x-ref` | `Any` | no | — |

### rolling-mean

`(rolling-mean window-size xs)`

Computes a moving average over sliding windows of `window-size` across `xs`.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `window-size` | `Any` | no | — |
| `xs` | `Any` | no | — |

### rolling-standard-deviation

`(rolling-standard-deviation window-size xs)`

Computes sliding sample standard deviation over windows of `window-size` across `xs`.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `window-size` | `Any` | no | — |
| `xs` | `Any` | no | — |

### sample-standard-deviation

`(sample-standard-deviation xs) -> Float`

Computes the sample standard deviation (`sqrt(sample-variance)`).

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `xs` | `(Array Any)` | no | — |

### sample-standard-deviation-given-mean

`(sample-standard-deviation-given-mean xs m) -> Float`

Computes sample standard deviation using provided mean estimate `m`.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `xs` | `(Array Any)` | no | — |
| `m` | `Float` | no | — |

### sample-variance

`(sample-variance xs m)`

Computes the sample variance (`1/(N-1)` Bessel-corrected denominator) of `xs`.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `xs` | `Any` | no | — |
| `m` | `Any` | no | — |

### sample-variance-given-mean

`(sample-variance-given-mean xs m)`

Computes sample variance (`1/(N-1)`) returning `NaN` when fewer than 2 samples exist.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `xs` | `Any` | no | — |
| `m` | `Any` | no | — |

### weighted-mean

`(weighted-mean xs ws)`

Computes the weighted arithmetic mean of values `xs` with weights `ws`.

| Parameter | Type | Optional | Description |
| :--- | :--- | :--- | :--- |
| `xs` | `Any` | no | — |
| `ws` | `Any` | no | — |
