public void SamplesFollowsCorrectDistribution()
        {
            var cd = new NormalGamma(1.0, 4.0, 3.0, 3.5);

            // Sample from the distribution.
            var samples = cd.Samples().Take(CommonDistributionTests.NumberOfTestSamples).ToArray();

            // Extract the mean and precisions.
            var means        = samples.Select(mp => mp.Mean);
            var precs        = samples.Select(mp => mp.Precision);
            var meanMarginal = cd.MeanMarginal();
            var precMarginal = cd.PrecisionMarginal();

            // Check the precision distribution.
            CommonDistributionTests.VapnikChervonenkisTest(
                CommonDistributionTests.Error,
                CommonDistributionTests.ErrorProbability,
                precs,
                precMarginal);

            // Check the mean distribution.
            CommonDistributionTests.VapnikChervonenkisTest(
                CommonDistributionTests.Error,
                CommonDistributionTests.ErrorProbability,
                means,
                meanMarginal);
        }
        public void SampleFollowsCorrectDistribution()
        {
            var cd = new NormalGamma(1.0, 4.0, 7.0, 3.5);

            // Sample from the distribution.
            var samples = new MeanPrecisionPair[CommonDistributionTests.NumberOfTestSamples];

            for (var i = 0; i < CommonDistributionTests.NumberOfTestSamples; i++)
            {
                samples[i] = cd.Sample();
            }

            // Extract the mean and precisions.
            var means        = samples.Select(mp => mp.Mean);
            var precs        = samples.Select(mp => mp.Precision);
            var meanMarginal = cd.MeanMarginal();
            var precMarginal = cd.PrecisionMarginal();

            // Check the precision distribution.
            CommonDistributionTests.VapnikChervonenkisTest(
                CommonDistributionTests.Error,
                CommonDistributionTests.ErrorProbability,
                precs,
                precMarginal);

            // Check the mean distribution.
            CommonDistributionTests.VapnikChervonenkisTest(
                CommonDistributionTests.Error,
                CommonDistributionTests.ErrorProbability,
                means,
                meanMarginal);
        }
        public void CanGetMeanMarginal([Values(0.0, 10.0, 10.0)] double meanLocation, [Values(1.0, 1.0, 1.0)] double meanScale, [Values(1.0, 2.0, 2.0)] double precShape, [Values(1.0, 2.0, Double.PositiveInfinity)] double precInvScale, [Values(0.0, 10.0, 10.0)] double meanMarginalMean, [Values(1.0, 1.0, 0.5)] double meanMarginalScale, [Values(2.0, 4.0, Double.PositiveInfinity)] double meanMarginalDoF)
        {
            var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale);
            var mm = ng.MeanMarginal();

            Assert.AreEqual(meanMarginalMean, mm.Location);
            Assert.AreEqual(meanMarginalScale, mm.Scale);
            Assert.AreEqual(meanMarginalDoF, mm.DegreesOfFreedom);
        }
        public void CanGetMeanMarginal(double meanLocation, double meanScale, double precShape, double precInvScale, double meanMarginalMean, double meanMarginalScale, double meanMarginalDoF)
        {
            var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale);
            var mm = ng.MeanMarginal();

            Assert.AreEqual(meanMarginalMean, mm.Location);
            Assert.AreEqual(meanMarginalScale, mm.Scale);
            Assert.AreEqual(meanMarginalDoF, mm.DegreesOfFreedom);
        }
        public void SamplesFollowsCorrectDistribution()
        {
            var cd = new NormalGamma(1.0, 4.0, 3.0, 3.5);

            // Sample from the distribution.
            var samples = cd.Samples().Take(CommonDistributionTests.NumberOfTestSamples).ToArray();

            // Extract the mean and precisions.
            var means = samples.Select(mp => mp.Mean);
            var precs = samples.Select(mp => mp.Precision);
            var meanMarginal = cd.MeanMarginal();
            var precMarginal = cd.PrecisionMarginal();

            // Check the precision distribution.
            CommonDistributionTests.VapnikChervonenkisTest(
                CommonDistributionTests.Error,
                CommonDistributionTests.ErrorProbability,
                precs,
                precMarginal);

            // Check the mean distribution.
            CommonDistributionTests.VapnikChervonenkisTest(
                CommonDistributionTests.Error,
                CommonDistributionTests.ErrorProbability,
                means,
                meanMarginal);
        }
        public void SampleFollowsCorrectDistribution()
        {
            var cd = new NormalGamma(1.0, 4.0, 7.0, 3.5);

            // Sample from the distribution.
            var samples = new MeanPrecisionPair[CommonDistributionTests.NumberOfTestSamples];
            for (var i = 0; i < CommonDistributionTests.NumberOfTestSamples; i++)
            {
                samples[i] = cd.Sample();
            }

            // Extract the mean and precisions.
            var means = samples.Select(mp => mp.Mean);
            var precs = samples.Select(mp => mp.Precision);
            var meanMarginal = cd.MeanMarginal();
            var precMarginal = cd.PrecisionMarginal();

            // Check the precision distribution.
            CommonDistributionTests.VapnikChervonenkisTest(
                CommonDistributionTests.Error,
                CommonDistributionTests.ErrorProbability,
                precs,
                precMarginal);

            // Check the mean distribution.
            CommonDistributionTests.VapnikChervonenkisTest(
                CommonDistributionTests.Error,
                CommonDistributionTests.ErrorProbability,
                means,
                meanMarginal);
        }
 public void CanGetMeanMarginal(double meanLocation, double meanScale, double precShape, double precInvScale, double meanMarginalMean, double meanMarginalScale, double meanMarginalDoF)
 {
     var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale);
     var mm = ng.MeanMarginal();
     Assert.AreEqual(meanMarginalMean, mm.Location);
     Assert.AreEqual(meanMarginalScale, mm.Scale);
     Assert.AreEqual(meanMarginalDoF, mm.DegreesOfFreedom);
 }
 public void CanGetMeanMarginal([Values(0.0, 10.0, 10.0)] double meanLocation, [Values(1.0, 1.0, 1.0)] double meanScale, [Values(1.0, 2.0, 2.0)] double precShape, [Values(1.0, 2.0, Double.PositiveInfinity)] double precInvScale, [Values(0.0, 10.0, 10.0)] double meanMarginalMean, [Values(1.0, 1.0, 0.5)] double meanMarginalScale, [Values(2.0, 4.0, Double.PositiveInfinity)] double meanMarginalDoF)
 {
     var ng = new NormalGamma(meanLocation, meanScale, precShape, precInvScale);
     var mm = ng.MeanMarginal();
     Assert.AreEqual(meanMarginalMean, mm.Location);
     Assert.AreEqual(meanMarginalScale, mm.Scale);
     Assert.AreEqual(meanMarginalDoF, mm.DegreesOfFreedom);
 }