public void GenerateTest1() { Accord.Math.Tools.SetupGenerator(0); double[] mean = { 2, 6 }; double[,] cov = { { 2, 1 }, { 1, 5 } }; var normal = new MultivariateNormalDistribution(mean, cov); double[][] source = normal.Generate(10000000); var target = new MultivariateEmpiricalDistribution(source); Assert.IsTrue(mean.IsEqual(target.Mean, 0.001)); Assert.IsTrue(cov.IsEqual(target.Covariance, 0.003)); double[][] samples = target.Generate(10000000); double[] sampleMean = samples.Mean(); double[,] sampleCov = samples.Covariance(); Assert.AreEqual(2, sampleMean[0], 1e-2); Assert.AreEqual(6, sampleMean[1], 1e-2); Assert.AreEqual(2, sampleCov[0, 0], 1e-2); Assert.AreEqual(1, sampleCov[0, 1], 1e-2); Assert.AreEqual(1, sampleCov[1, 0], 1e-2); Assert.AreEqual(5, sampleCov[1, 1], 2e-2); }