public NormalDistribution(double[] mean, double[,] covariance)
: base(mean.Length)
{
int k = mean.Length;
this.mean = mean;
this.covariance = covariance;
variance = covariance.Diagonal();
double detSqrt = System.Math.Sqrt(System.Math.Abs(covariance.Determinant()));
constant = 1.0/(System.Math.Pow(2.0*System.Math.PI, k/2.0)*detSqrt);
chol = new CholeskyDecomposition(covariance, true);
if (chol.Determinant == 0)
{
// The covariance matrix is singular, use pseudo-inverse
svd = new SingularValueDecomposition(covariance);
}
}