Computing Deviations

Computing Deviations

This package provides functions to compute various deviations between arrays in a variety of ways:

StatsBase.counteqFunction.
counteq(a, b)

Count the number of indices at which the elements of the arrays a and b are equal.

source
StatsBase.countneFunction.
countne(a, b)

Count the number of indices at which the elements of the arrays a and b are not equal.

source
StatsBase.sqL2distFunction.
sqL2dist(a, b)

Compute the squared L2 distance between two arrays: $\sum_{i=1}^n |a_i - b_i|^2$. Efficient equivalent of sumabs2(a - b).

source
StatsBase.L2distFunction.
L2dist(a, b)

Compute the L2 distance between two arrays: $\sqrt{\sum_{i=1}^n |a_i - b_i|^2}$. Efficient equivalent of sqrt(sumabs2(a - b)).

source
StatsBase.L1distFunction.
L1dist(a, b)

Compute the L1 distance between two arrays: $\sum_{i=1}^n |a_i - b_i|$. Efficient equivalent of sum(abs, a - b).

source
StatsBase.LinfdistFunction.
Linfdist(a, b)

Compute the L∞ distance, also called the Chebyshev distance, between two arrays: $\max_{i\in1:n} |a_i - b_i|$. Efficient equivalent of maxabs(a - b).

source
StatsBase.gkldivFunction.
gkldiv(a, b)

Compute the generalized Kullback-Leibler divergence between two arrays: $\sum_{i=1}^n (a_i \log(a_i/b_i) - a_i + b_i)$. Efficient equivalent of sum(a*log(a/b)-a+b).

source
StatsBase.meanadFunction.
meanad(a, b)

Return the mean absolute deviation between two arrays: mean(abs(a - b)).

source
StatsBase.maxadFunction.
maxad(a, b)

Return the maximum absolute deviation between two arrays: maxabs(a - b).

source
StatsBase.msdFunction.
msd(a, b)

Return the mean squared deviation between two arrays: mean(abs2(a - b)).

source
StatsBase.rmsdFunction.
rmsd(a, b; normalize=false)

Return the root mean squared deviation between two optionally normalized arrays. The root mean squared deviation is computed as sqrt(msd(a, b)).

source
StatsBase.psnrFunction.
psnr(a, b, maxv)

Compute the peak signal-to-noise ratio between two arrays a and b. maxv is the maximum possible value either array can take. The PSNR is computed as 10 * log10(maxv^2 / msd(a, b)).

source
Note

All these functions are implemented in a reasonably efficient way without creating any temporary arrays in the middle.