statistics.jl

Unit for statistics, probability and related functions.

CategoryOutput
1. Probabilityfunctions relating to probability
2. Descriptive Statisticsfunctions relating to decriptive statistics

Probability

FunctionDescription
softmaxcompute softmax probabilities
PosDefManifold.softmaxFunction
softmax(χ::Vector{T}) where T<:Real

Given a real vector of $k$ non-negative scores $χ=c_1,...,c_k$, return the vector $π=p_1,...,p_k$ of their softmax probabilities, as per

$p_i=\frac{\textrm{e}^{c_i}}{\sum_{i=1}^{k}\textrm{e}^{c_i}}$.

Examples

χ=[1.0, 2.3, 0.4, 5.0]
π=softmax(χ)

Descriptive Statistics

FunctionDescription
meanscalar mean of real or complex numbers according to the specified metric
stdscalar standard deviation of real or complex numbers according to the specified metric
mean(metric::Metric, ν::Vector{T}) where T<:RealOrComplex

See bottom of documentation of general function mean

Statistics.stdFunction
std(metric::Metric, ν::Vector{T};
    corrected::Bool=true,
    mean=nothing) where T<:RealOrComplex

Standard deviation of $k$ real or complex scalars, using the specified metric of type Metric::Enumerated type and the specified mean if provided.

Only the Euclidean and Fisher metric are supported by this function. Using the Euclidean metric return the output of standard Julia std function. Using the Fisher metric return the scalar geometric standard deviation, which is defined such as,

$\sigma=\text{exp}\Big(\sqrt{k^{-1}\sum_{i=1}^{k}\text{ln}^2(v_i/\mu})\Big)$.

If corrected is true, then the sum is scaled with $k-1$, whereas if it is false the sum is scaled with $k$.

Examples

using PosDefManifold
# Generate 10 random numbers distributed as a chi-square with 2 df.
ν=[randχ²(2) for i=1:10]
arithmetic_sd=std(Euclidean, ν) # mean not provided
geometric_mean=mean(Fisher, ν)
geometric_sd=std(Fisher, ν, mean=geometric_mean) # mean provided