public void TestIntegrateDistribution(double[] x, double[] mu, double[,] sigma, double expected, double error)
        {
            var sampler = new MultivariateNormalSampler.Builder(mu, sigma).Build(new ReducedThreeFry4X64(1));
            var actual  = SamplerTester.IntegrateMultivariateCdf(sampler, x, Trials);

            Assert.AreEqual(actual, expected, error);
        }
        public void TestConstructValid()
        {
            var covarianceMatrix = new[, ]
            {
                { 1.0, 0.5 },
                { 0.5, 1.0 },
            };

            var mean   = new[] { 0.0, 0.0 };
            var engine = MersenneTwister32Bit19937.InitGenRand(1);

            Assert.DoesNotThrow(() => _ = new MultivariateNormalSampler.Builder(mean, covarianceMatrix).Build(engine));
        }
        public void TestLength()
        {
            var mean  = new[] { 0d, 0d };
            var sigma = new[, ]
            {
                { 1d, 0.5 },
                { 0.5, 1d },
            };
            var engine  = MersenneTwister32Bit19937.InitGenRand(1);
            var sampler = new MultivariateNormalSampler.Builder(mean, sigma).Build(engine);

            Assert.AreEqual(2, sampler.Length);
        }
        public void TestInvalidMean()
        {
            var inputCovariance = new[, ]
            {
                { 1.0, 0.5 },
                { 0.5, 1.0 },
            };

            Assert.Throws <ArgumentException>(
                () => _ = new MultivariateNormalSampler.Builder(new[] { 0d }, inputCovariance));

            Assert.Throws <ArgumentException>(
                () => _ = new MultivariateNormalSampler.Builder(new[] { 0d, double.NaN }, inputCovariance));

            Assert.Throws <ArgumentNullException>(
                () => _ = new MultivariateNormalSampler.Builder(null, inputCovariance));

            Assert.Throws <ArgumentNullException>(
                () => _ = new MultivariateNormalSampler.Builder(new[] { 0d }, null));
        }