## lamina.stats documentation

### moving-average

#### fn

Returns a channel that will periodically emit the moving average over all messages emitted by
the source channel every `period`

milliseconds, defaulting to once every five seconds. This
moving average is exponentially weighted to the last `window`

milliseconds, defaulting to the
last five minutes.

### moving-quantiles

#### fn

Returns a channel that will periodically emit a map of quantile values every `period`

millseconds, which represent the statistical distribution of values emitted by the source
channel, weighted towards the last `window`

milliseconds.

The map will be of quantile onto quantile value, so for a uniform distribution of values from 1..1000, it would emit

{0.5 500, 0.75 750, 0.95 950, 0.99 990, 0.999 999}

By default, the above quantiles will be used, these can be specified as a sequence of quantiles of the form [0.5 0.75 0.99 0.999].

### moving-sample

#### fn

Accumulates a representative sample of values passing through the channel, biased towards values within the
last `window`

milliseconds.

The current sample is emitted every `period`

milliseconds.

### outliers

#### fn

Returns a channel that will emit outliers from the source channel, as measured by the standard deviations from the mean value of (facet msg). Outlier status is determined by 'variance-predicate', which is given the standard deviations from the mean, and returns true or false. By default, it will return true for any value where the absolute value is greater than three.

For instance, to monitor function calls that take an unusually long or short time via a
`return`

probe:

(outliers :duration (probe-channel :name:return))

To only receive outliers that are longer than the mean, define a custom :predicate

(outliers :duration {:window (lamina.time/minutes 15) :variance-predicate #(< % 3)} (probe-channel :name:return))

:window describes the window of the moving average, which defaults to five minutes. This can be used to adjust the responsiveness to long-term changes to the mean.

### quantiles

#### fn

Returns a channel that will periodically emit a map of quantile values every `period`

millseconds, which represent the statistical distribution of values emitted by the source
channel.

The map will be of quantile onto quantile value, so for a uniform distribution of values from 1..1000, it would emit

{0.5 500, 0.75 750, 0.95 950, 0.99 990, 0.999 999}

By default, the above quantiles will be used, these can be specified as a sequence of quantiles of the form [0.5 0.75 0.99 0.999].

### rate

#### fn

Returns a channel that will periodically emit the number of messages emitted by the source
channel over the last `period`

milliseconds, with a default of 1000.

### sample

#### fn

Accumulates a representative sample of values passing through the channel.

The current sample is emitted every `period`

milliseconds.

### sum

#### fn

Returns a channel that will periodically emit the sum of all messages emitted by the source
channel over the last `period`

milliseconds, with a default of 1000.

It is assumed that all numbers emitted by the source channel are integral values.

### variance

#### fn

Returns a channel that will periodically emit the variance of all values emitted by the source
channel every `period`

milliseconds.