Engee documentation

Computing Deviations

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

counteq(a, b)

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

countne(a, b)

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

sqL2dist(a, b)

Compute the squared L2 distance between two arrays: . Efficient equivalent of sum(abs2, a - b).

L2dist(a, b)

Compute the L2 distance between two arrays: . Efficient equivalent of sqrt(sum(abs2, a - b)).

L1dist(a, b)

Compute the L1 distance between two arrays: . Efficient equivalent of sum(abs, a - b).

Linfdist(a, b)

Compute the L∞ distance, also called the Chebyshev distance, between two arrays: . Efficient equivalent of maxabs(a - b).

gkldiv(a, b)

Compute the generalized Kullback-Leibler divergence between two arrays: . Efficient equivalent of sum(a*log(a/b)-a+b).

meanad(a, b)

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

maxad(a, b)

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

msd(a, b)

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

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)).

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)).

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