public void CumulativeFunctionTest1()
{
// Comparison against dmvnorm from the mvtnorm R package
double[] mean = { 1, -1 };
double[,] covariance =
{
{ 0.9, 0.4 },
{ 0.4, 0.3 },
};
var target = new MultivariateNormalDistribution(mean, covariance);
double[] x = { 1.2, -0.8 };
// dmvnorm(x=c(1.2, -0.8), mean=c(1, -1), sigma=matrix(c(0.9, 0.4, 0.4, 0.3), 2, 2))
double pdf = target.ProbabilityDensityFunction(x);
// pmvnorm(upper=c(1.2, -0.8), mean=c(1, -1), sigma=matrix(c(0.9, 0.4, 0.4, 0.3), 2, 2))
double cdf = target.DistributionFunction(x);
// pmvnorm(lower=c(1.2, -0.8), mean=c(1, -1), sigma=matrix(c(0.9, 0.4, 0.4, 0.3), 2, 2))
double ccdf = target.ComplementaryDistributionFunction(x);
Assert.AreEqual(0.44620942136345987, pdf);
Assert.AreEqual(0.5049523013014460826, cdf, 1e-10);
Assert.AreEqual(0.27896707550525140507, ccdf, 1e-10);
}