CrucibleBench.Stats (CrucibleBench v0.3.2)

View Source

Core statistical functions and utilities.

Provides basic statistical calculations used throughout the framework.

Summary

Functions

Calculate correlation coefficient between two variables.

Calculate kurtosis of a distribution.

Calculate mean (average) of a list of numbers.

Calculate median of a list of numbers.

Calculate quantile at given probability.

Rank values in ascending order, handling ties by averaging.

Calculate standard error of the mean.

Calculate skewness of a distribution.

Calculate standard deviation of a list of numbers.

Calculate variance of a list of numbers.

Calculate z-score for each value in a list.

Functions

correlation(x, y)

Calculate correlation coefficient between two variables.

Returns Pearson correlation coefficient (-1 to 1).

Examples

iex> x = [1, 2, 3, 4, 5]
iex> y = [2, 4, 6, 8, 10]
iex> CrucibleBench.Stats.correlation(x, y)
1.0

kurtosis(values)

Calculate kurtosis of a distribution.

Excess kurtosis > 0 means heavy tails (leptokurtic). Excess kurtosis < 0 means light tails (platykurtic).

mean(values)

Calculate mean (average) of a list of numbers.

Examples

iex> CrucibleBench.Stats.mean([1, 2, 3, 4, 5])
3.0

median(values)

Calculate median of a list of numbers.

Examples

iex> CrucibleBench.Stats.median([1, 2, 3, 4, 5])
3.0

iex> CrucibleBench.Stats.median([1, 2, 3, 4])
2.5

quantile(values, p)

Calculate quantile at given probability.

Examples

iex> CrucibleBench.Stats.quantile([1, 2, 3, 4, 5], 0.5)
3.0

rank(values)

Rank values in ascending order, handling ties by averaging.

Examples

iex> CrucibleBench.Stats.rank([5, 2, 8, 2, 9])
[3.0, 1.5, 4.0, 1.5, 5.0]

sem(values)

Calculate standard error of the mean.

Examples

iex> CrucibleBench.Stats.sem([1, 2, 3, 4, 5])
0.7071067811865476

skewness(values)

Calculate skewness of a distribution.

Positive skew means right tail is longer. Negative skew means left tail is longer.

stdev(values, opts \\ [])

Calculate standard deviation of a list of numbers.

Examples

iex> CrucibleBench.Stats.stdev([1, 2, 3, 4, 5])
1.5811388300841898

variance(values, opts \\ [])

Calculate variance of a list of numbers.

Options

  • :sample - If true (default), uses n-1 denominator (sample variance)
  • :population - If true, uses n denominator (population variance)

Examples

iex> CrucibleBench.Stats.variance([1, 2, 3, 4, 5])
2.5

z_scores(values)

Calculate z-score for each value in a list.

Examples

iex> CrucibleBench.Stats.z_scores([1, 2, 3, 4, 5])
[-1.2649110640673518, -0.6324555320336759, 0.0, 0.6324555320336759, 1.2649110640673518]