statistics.jl

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
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(χ)
source

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) where T<:RealOrComplex

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

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_mean=mean(Euclidean, ν)
geometric_mean=mean(Fisher, ν)
arithmetic_sd=std(Euclidean, ν)
geometric_sd=std(Fisher, ν)
source