Computing Deviations

Computing Deviations

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

StatsBase.counteq — Function.
counteq(a, b)

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

source
StatsBase.countne — Function.
countne(a, b)

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

source
StatsBase.sqL2dist — Function.
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.L2dist — Function.
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.L1dist — Function.
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.Linfdist — Function.
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.gkldiv — Function.
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.meanad — Function.
meanad(a, b)

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

source
StatsBase.maxad — Function.
maxad(a, b)

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

source
StatsBase.msd — Function.
msd(a, b)

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

source
StatsBase.rmsd — Function.
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.psnr — Function.
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.