The following program evaluates the squared Mahalanobis distance,
,
of the vector from the mean of a multivariate normal distribution with covariance matrix and mean given by
.
Imports System.Diagnostics
Module MainModule
Sub Main()
Dim arand As New AMOSRANDOMLib6.AmosRanGen
Dim Cov(2) As Double
Dim Mean(1) As Double
Cov(0) = 3
Cov(1) = 1
Cov(2) = 2
Mean(0) = 4
Mean(1) = 5
Dim Rank As Integer
Dim sqrdet As Double
Call arand.InstantSqrt(2, Cov(0), Rank, sqrdet)
Dim D2 As Double
Dim ef As Integer
Dim x(1) As Double
x(0) = 6
x(1) = 7
Call arand.MahalanobisD2(2, Cov(0), Mean(0), x(0), D2, ef)
If ef = 0 Then
Debug.WriteLine("Squared Mahalanobis distance = " & D2)
Else
Debug.WriteLine("Error")
End If
End Sub
End Module