StreamStats v0.1.0 StreamStats View Source

Enables concurrent calculation of count, mean and standard deviation. New values can be aggregated into an existing stat tuple and two stat tuples can be merged into one.

Inspired by the following article by John D. Cook: https://www.johndcook.com/blog/skewness_kurtosis/

Link to this section Summary

Functions

Aggregates a number or stats tuple into a stats tuple.

Merges two stats tuples. Implemented as Chan's Parallel Algorithm.

Adds a value to the aggregated stats tuple. Implemented as Welford's Online algorithm.

Aggregates the values in a list to a stats tuple.

Calculates the standard deviation using a stats tuple.

Calculates the variance using a stats tuple.

Link to this section Types

Link to this section Functions

Link to this function

combine(stats_a, stats_b)

View Source
combine(number() | t(), t()) :: t()

Aggregates a number or stats tuple into a stats tuple.

First argument can be a number or stats tuple.

Link to this function

combine_stats(stats_a, stats_b)

View Source
combine_stats(nil | t(), t()) :: t()

Merges two stats tuples. Implemented as Chan's Parallel Algorithm.

https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Parallel_algorithm

Link to this function

push_value(value, arg2)

View Source
push_value(number(), nil | t()) :: t()

Adds a value to the aggregated stats tuple. Implemented as Welford's Online algorithm.

https://en.wikipedia.org/wiki/Algorithms_for_calculating_variance#Welford's_Online_algorithm

Link to this function

reduce(values, stats \\ nil)

View Source
reduce(Enum.t(), t() | nil) :: any()

Aggregates the values in a list to a stats tuple.

Link to this function

standard_deviation(stats)

View Source
standard_deviation(t()) :: number()

Calculates the standard deviation using a stats tuple.

Link to this function

variance(stats)

View Source
variance(t()) :: number()

Calculates the variance using a stats tuple.