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 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);
        }