mahalanobis_sq#

anri.fwd.mahalanobis_sq(centroid, coord, inv_cov)[source]#

Get squared Mahalanobis distance for a coordinate given a centroid and an inverse covariance matrix.

See prepare_cov() for preparation of inv_cov.

Parameters:
  • centroid (Array) – [N] Coordinate of peak centroid in N dimensions

  • coord (Array) – [N] Query coordinate in N dimensions

  • inv_cov (Array) – Inverse covariance matrix, from prepare_cov()

Returns:

d2 (jax.Array) – Squared Mahalanobis distance

Notes

From Wikipedia [1]:

Given two points \(\vec{x}\) and \(\vec{y}\), the squared Mahalanobis distance between them with respect to a probability distribution \(Q\), that has a positiuve semi-definite covariance matrix \(\matr{\Sigma}\) is:

\[d_{M}\left(\vec{x},\vec{y},Q\right)^2 = \left(\vec{x}-\vec{y}\right)^{\intercal}\matr{\Sigma}^{-1}\left(\vec{x}-\vec{y}\right)\]

References