Пример #1
0
        public void Bug2811()
        {
            ChiSquaredDistribution d = new ChiSquaredDistribution(1798);
            double x = d.InverseLeftProbability(0.975);

            Console.WriteLine(x);
        }
Пример #2
0
        public void FisherTest()
        {
            // we will need a RNG
            Random rng = new Random(314159);

            int n1 = 1;
            int n2 = 2;

            // define chi squared distributions
            ContinuousDistribution d1 = new ChiSquaredDistribution(n1);
            ContinuousDistribution d2 = new ChiSquaredDistribution(n2);

            // create a sample of chi-squared variates
            Sample s = new Sample();

            for (int i = 0; i < 250; i++)
            {
                double x1 = d1.InverseLeftProbability(rng.NextDouble());
                double x2 = d2.InverseLeftProbability(rng.NextDouble());
                double x  = (x1 / n1) / (x2 / n2);
                s.Add(x);
            }

            // it should match a Fisher distribution with the appropriate parameters
            ContinuousDistribution f0 = new FisherDistribution(n1, n2);
            TestResult             t0 = s.KuiperTest(f0);

            Console.WriteLine(t0.LeftProbability);
            Assert.IsTrue(t0.LeftProbability < 0.95);

            // it should be distinguished from a Fisher distribution with different parameters
            ContinuousDistribution f1 = new FisherDistribution(n1 + 1, n2);
            TestResult             t1 = s.KuiperTest(f1);

            Console.WriteLine(t1.LeftProbability);
            Assert.IsTrue(t1.LeftProbability > 0.95);
        }