stat: generalise Mehalanobis vector parameters

This commit is contained in:
kortschak
2017-12-28 09:30:10 +10:30
committed by Dan Kortschak
parent cd47c93d54
commit 6f65e4ee2e

View File

@@ -130,11 +130,11 @@ func corrToCov(c *mat.SymDense, sigma []float64) {
// Mahalanobis computes the Mahalanobis distance
// D = sqrt((x-y)^T * Σ^-1 * (x-y))
// between the vectors x and y given the cholesky decomposition of Σ.
// between the column vectors x and y given the cholesky decomposition of Σ.
// Mahalanobis returns NaN if the linear solve fails.
//
// See https://en.wikipedia.org/wiki/Mahalanobis_distance for more information.
func Mahalanobis(x, y *mat.VecDense, chol *mat.Cholesky) float64 {
func Mahalanobis(x, y mat.Vector, chol *mat.Cholesky) float64 {
var diff mat.VecDense
diff.SubVec(x, y)
var tmp mat.VecDense