예제 #1
0
        public void CanSampleSequence()
        {
            var n   = new Chi(1.0);
            var ied = n.Samples();

            GC.KeepAlive(ied.Take(5).ToArray());
        }
예제 #2
0
        public void ValidateDensityLn(double dof, double x, double expected)
        {
            var chi = new Chi(dof);

            Assert.That(chi.DensityLn(x), Is.EqualTo(expected).Within(13));
            Assert.That(Chi.PDFLn(dof, x), Is.EqualTo(expected).Within(13));
        }
예제 #3
0
        public void ValidateToString()
        {
            System.Threading.Thread.CurrentThread.CurrentCulture = System.Globalization.CultureInfo.InvariantCulture;
            var n = new Chi(1.0);

            Assert.AreEqual("Chi(k = 1)", n.ToString());
        }
 public void SetDofFailsWithNonPositiveDoF(double dof)
 {
     {
         var n = new Chi(1.0);
         n.DegreesOfFreedom = dof;
     }
 }
예제 #5
0
        public void ValidateCumulativeDistribution(double dof, double x)
        {
            var    n        = new Chi(dof);
            double expected = SpecialFunctions.GammaLowerIncomplete(dof / 2.0, x * x / 2.0) / SpecialFunctions.Gamma(dof / 2.0);

            Assert.AreEqual(expected, n.CumulativeDistribution(x));
            Assert.AreEqual(expected, Chi.CDF(dof, x));
        }
예제 #6
0
        public void ValidateDensityLn(double dof, double x)
        {
            var    n        = new Chi(dof);
            double expected = ((1.0 - (dof / 2.0)) * Math.Log(2.0)) + ((dof - 1.0) * Math.Log(x)) - (x * (x / 2.0)) - SpecialFunctions.GammaLn(dof / 2.0);

            Assert.AreEqual(expected, n.DensityLn(x));
            Assert.AreEqual(expected, Chi.PDFLn(dof, x));
        }
예제 #7
0
        public void ValidateDensity(double dof, double x)
        {
            var    n        = new Chi(dof);
            double expected = (Math.Pow(2.0, 1.0 - (dof / 2.0)) * Math.Pow(x, dof - 1.0) * Math.Exp(-x * (x / 2.0))) / SpecialFunctions.Gamma(dof / 2.0);

            Assert.AreEqual(expected, n.Density(x));
            Assert.AreEqual(expected, Chi.PDF(dof, x));
        }
예제 #8
0
파일: ChiTests.cs 프로젝트: wibble82/mmbot
        public void ValidateCumulativeDistribution(
            [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double dof,
            [Values(0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity)] double x)
        {
            var n = new Chi(dof);

            Assert.AreEqual(SpecialFunctions.GammaLowerIncomplete(dof / 2.0, x * x / 2.0) / SpecialFunctions.Gamma(dof / 2.0), n.CumulativeDistribution(x));
        }
예제 #9
0
파일: ChiTests.cs 프로젝트: wibble82/mmbot
        public void ValidateDensityLn(
            [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double dof,
            [Values(0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity)] double x)
        {
            var n = new Chi(dof);

            Assert.AreEqual(((1.0 - (dof / 2.0)) * Math.Log(2.0)) + ((dof - 1.0) * Math.Log(x)) - (x * (x / 2.0)) - SpecialFunctions.GammaLn(dof / 2.0), n.DensityLn(x));
        }
예제 #10
0
파일: ChiTests.cs 프로젝트: wibble82/mmbot
        public void ValidateDensity(
            [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double dof,
            [Values(0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity)] double x)
        {
            var n = new Chi(dof);

            Assert.AreEqual((Math.Pow(2.0, 1.0 - (dof / 2.0)) * Math.Pow(x, dof - 1.0) * Math.Exp(-x * (x / 2.0))) / SpecialFunctions.Gamma(dof / 2.0), n.Density(x));
        }
예제 #11
0
        public void ValidateMode(double dof)
        {
            var n = new Chi(dof);

            if (dof >= 1)
            {
                Assert.AreEqual(Math.Sqrt(dof - 1), n.Mode);
            }
        }
예제 #12
0
파일: ChiTests.cs 프로젝트: wibble82/mmbot
        public void ValidateMode([Values(1.0, 2.0, 2.5, 3.0, Double.PositiveInfinity)] double dof)
        {
            var n = new Chi(dof);

            if (dof >= 1)
            {
                Assert.AreEqual(Math.Sqrt(dof - 1), n.Mode);
            }
        }
예제 #13
0
        public void ValidateCumulativeDistribution(double dof, double x, double expected)
        {
            var chi = new Chi(dof);

            Assert.That(chi.CumulativeDistribution(x), Is.EqualTo(expected).Within(13));
            Assert.That(Chi.CDF(dof, x), Is.EqualTo(expected).Within(13));
            //double expected = SpecialFunctions.GammaLowerIncomplete(dof / 2.0, x * x / 2.0) / SpecialFunctions.Gamma(dof / 2.0);
            //Assert.AreEqual(expected, n.CumulativeDistribution(x));
            //Assert.AreEqual(expected, Chi.CDF(dof, x));
        }
예제 #14
0
        public void chi()
        {
            var rand = new Random(Seed);
            var r    = 10;

            var chi = new Chi(r, rand);

            Assert.True(Math.Abs(0.05 - chi.GetCdf(3.94)) < 0.001);
            Assert.True(Math.Abs(0.999 - chi.GetCdf(29.59)) < 0.001);
        }
예제 #15
0
        public void inverse_chi()
        {
            var rand = new Random(Seed);
            var n    = 1000;
            var r    = 10;

            var chi = new Chi(r, rand);

            var samples = chi.GenerateSample(n);

            Assert.True(Math.Abs(r - samples.Mean()) < 0.5);
            Assert.True(Math.Abs(2 * r - samples.Variance()) < 1.5);
        }
예제 #16
0
    public static void chi_square_noncentral_cdf_values_test()
    //****************************************************************************80
    //
    //  Purpose:
    //
    //    CHI_SQUARE_NONCENTRAL_CDF_VALUES_TEST tests CHI_SQUARE_NONCENTRAL_CDF_VALUES.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    09 February 2007
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        int    df     = 0;
        double fx     = 0;
        double lambda = 0;
        double x      = 0;

        Console.WriteLine("");
        Console.WriteLine("CHI_SQUARE_NONCENTRAL_CDF_VALUES_TEST:");
        Console.WriteLine("  CHI_SQUARE_NONCENTRAL_CDF_VALUES returns values of");
        Console.WriteLine("  the noncentral Chi-Squared Cumulative Density Function.");
        Console.WriteLine("");
        Console.WriteLine("      X      LAMBDA     DF     CDF");
        Console.WriteLine("");
        int n_data = 0;

        for (;;)
        {
            Chi.chi_square_noncentral_cdf_values(ref n_data, ref df, ref lambda, ref x, ref fx);
            if (n_data == 0)
            {
                break;
            }

            Console.WriteLine("  "
                              + x.ToString(CultureInfo.InvariantCulture).PadLeft(10) + "  "
                              + lambda.ToString(CultureInfo.InvariantCulture).PadLeft(8) + "  "
                              + df.ToString(CultureInfo.InvariantCulture).PadLeft(4) + "  "
                              + fx.ToString(CultureInfo.InvariantCulture).PadLeft(12) + "");
        }
    }
예제 #17
0
    public static void scaled_inverse_chi_square_pdf_values_test( )
    //****************************************************************************80
    //
    //  Purpose:
    //
    //    SCALED_INVERSE_CHI_SQUARE_PDF_VALUES_TEST tests SCALED_INVERSE_CHI_SQUARE_PDF_VALUES.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    05 August 2015
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        double df = 0;
        double fx = 0;
        double x  = 0;
        double xi = 0;

        Console.WriteLine("");
        Console.WriteLine("SCALED_INVERSE_CHI_SQUARE_PDF_VALUES_TEST:");
        Console.WriteLine("  SCALED_INVERSE_CHI_SQUARE_PDF_VALUES returns values of ");
        Console.WriteLine("  the scaled inverse Chi-Square Probability Density Function.");
        Console.WriteLine("");
        Console.WriteLine("     DF        XI        X    PDF");
        Console.WriteLine("");
        int n_data = 0;

        for ( ; ;)
        {
            Chi.scaled_inverse_chi_square_pdf_values(ref n_data, ref df, ref xi, ref x, ref fx);
            if (n_data == 0)
            {
                break;
            }
            Console.WriteLine("  "
                              + df.ToString(CultureInfo.InvariantCulture).PadLeft(8) + "  "
                              + xi.ToString(CultureInfo.InvariantCulture).PadLeft(8) + "  "
                              + x.ToString(CultureInfo.InvariantCulture).PadLeft(8) + "  "
                              + fx.ToString(CultureInfo.InvariantCulture).PadLeft(12) + "");
        }
    }
예제 #18
0
    public static void chi_values_test()
    //****************************************************************************80
    //
    //  Purpose:
    //
    //    CHI_VALUES_TEST tests CHI_VALUES.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    11 June 2007
    //
    //  Author:
    //
    //    John Burkardt
    //
    {
        double fx = 0;
        double x  = 0;

        Console.WriteLine("");
        Console.WriteLine("CHI_VALUES_TEST:");
        Console.WriteLine("  CHI_VALUES stores values of");
        Console.WriteLine("  the Hyperbolic Cosine Integral function CHI(X).");
        Console.WriteLine("");
        Console.WriteLine("      X            CHI(X)");
        Console.WriteLine("");
        int n_data = 0;

        for (;;)
        {
            Chi.chi_values(ref n_data, ref x, ref fx);
            if (n_data == 0)
            {
                break;
            }

            Console.WriteLine("  "
                              + x.ToString(CultureInfo.InvariantCulture).PadLeft(12) + "  "
                              + fx.ToString(CultureInfo.InvariantCulture).PadLeft(12) + "");
        }
    }
예제 #19
0
    public static double maxwell_sample(double a, ref int seed)
    //****************************************************************************80
    //
    //  Purpose:
    //
    //    MAXWELL_SAMPLE samples the Maxwell PDF.
    //
    //  Licensing:
    //
    //    This code is distributed under the GNU LGPL license.
    //
    //  Modified:
    //
    //    16 October 2004
    //
    //  Author:
    //
    //    John Burkardt
    //
    //  Parameters:
    //
    //    Input, double A, the parameter of the PDF.
    //    0 < A.
    //
    //    Input/output, int &SEED, a seed for the random number generator.
    //
    //    Output, double MAXWELL_SAMPLE, a sample of the PDF.
    //
    {
        const double a2 = 3.0;
        double       x  = Chi.chi_square_sample(a2, ref seed);

        x = a * Math.Sqrt(x);

        return(x);
    }
예제 #20
0
 public void ValidateCumulativeDistribution(double dof, double x)
 {
     var n = new Chi(dof);
     Assert.AreEqual<double>(SpecialFunctions.GammaLowerIncomplete(dof / 2.0, x * x / 2.0) / SpecialFunctions.Gamma(dof / 2.0), n.CumulativeDistribution(x));
 }
예제 #21
0
 public void ValidateMode(double dof)
 {
     var n = new Chi(dof);
     if (dof >= 1)
     {
         Assert.AreEqual<double>(Math.Sqrt(dof - 1), n.Mode);
     }
 }
예제 #22
0
        public void ValidateVariance(double dof)
        {
            var n = new Chi(dof);

            Assert.AreEqual(dof - (n.Mean * n.Mean), n.Variance);
        }
예제 #23
0
 public void ValidateDensityLn(double dof, double x)
 {
     var n = new Chi(dof);
     Assert.AreEqual<double>((1.0 - dof / 2.0) * Math.Log(2.0) + (dof - 1.0) * Math.Log(x) - x * x / 2.0 - SpecialFunctions.GammaLn(dof / 2.0), n.DensityLn(x));
 }
예제 #24
0
 public void ValidateToString()
 {
     var n = new Chi(1.0);
     Assert.AreEqual("Chi(DoF = 1)", n.ToString());
 }
예제 #25
0
 public void ValidateCumulativeDistribution(
     [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double dof, 
     [Values(0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity)] double x)
 {
     var n = new Chi(dof);
     Assert.AreEqual(SpecialFunctions.GammaLowerIncomplete(dof / 2.0, x * x / 2.0) / SpecialFunctions.Gamma(dof / 2.0), n.CumulativeDistribution(x));
 }
예제 #26
0
 public void CanSample()
 {
     var n = new Chi(1.0);
     n.Sample();
 }
예제 #27
0
        public IActionResult Status()
        {
            Chi myChi = new Chi();

            return(View("Status", myChi));
        }
예제 #28
0
 public void SetDofFailsWithNonPositiveDoF(double dof)
 {
     {
         var n = new Chi(1.0);
         n.DegreesOfFreedom = dof;
     }
 }
예제 #29
0
 public void ChiCreateFailsWithBadParameters(double dof)
 {
     var n = new Chi(dof);
 }
예제 #30
0
 public void CanSetDoF(double dof)
 {
     var n = new Chi(1.0);
     n.DegreesOfFreedom = dof;
 }
예제 #31
0
 public void CanCreateChi(double dof)
 {
     var n = new Chi(dof);
     Assert.AreEqual<double>(dof, n.DegreesOfFreedom);
 }
예제 #32
0
 public void ValidateVariance(double dof)
 {
     var n = new Chi(dof);
     Assert.AreEqual<double>(dof - n.Mean * n.Mean, n.Variance);
 }
예제 #33
0
 public void ValidateStdDev(double dof)
 {
     var n = new Chi(dof);
     Assert.AreEqual<double>(Math.Sqrt(n.Variance), n.StdDev);
 }
예제 #34
0
 public void ValidateDensity(
     [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double dof, 
     [Values(0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity)] double x)
 {
     var n = new Chi(dof);
     Assert.AreEqual((Math.Pow(2.0, 1.0 - (dof / 2.0)) * Math.Pow(x, dof - 1.0) * Math.Exp(-x * (x / 2.0))) / SpecialFunctions.Gamma(dof / 2.0), n.Density(x));
 }
예제 #35
0
 public void ValidateDensityLn(
     [Values(1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.0, 2.5, 2.5, 2.5, 2.5, 2.5, 2.5, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity, Double.PositiveInfinity)] double dof, 
     [Values(0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity, 0.0, 0.1, 1.0, 5.5, 110.1, Double.PositiveInfinity)] double x)
 {
     var n = new Chi(dof);
     Assert.AreEqual(((1.0 - (dof / 2.0)) * Math.Log(2.0)) + ((dof - 1.0) * Math.Log(x)) - (x * (x / 2.0)) - SpecialFunctions.GammaLn(dof / 2.0), n.DensityLn(x));
 }
예제 #36
0
        public void CanCreateChi(double dof)
        {
            var n = new Chi(dof);

            Assert.AreEqual(dof, n.DegreesOfFreedom);
        }
예제 #37
0
 public void CanSampleSequence()
 {
     var n = new Chi(1.0);
     var ied = n.Samples();
     ied.Take(5).ToArray();
 }
예제 #38
0
        public void ValidateMean(double dof)
        {
            var n = new Chi(dof);

            Assert.AreEqual(Constants.Sqrt2 * (SpecialFunctions.Gamma((dof + 1.0) / 2.0) / SpecialFunctions.Gamma(dof / 2.0)), n.Mean);
        }
예제 #39
0
 public void CanCreateChi([Values(1.0, 3.0, Double.PositiveInfinity)] double dof)
 {
     var n = new Chi(dof);
     Assert.AreEqual(dof, n.DegreesOfFreedom);
 }
예제 #40
0
 public void ValidateMean(double dof)
 {
     var n = new Chi(dof);
     Assert.AreEqual<double>(Math.Sqrt(2) * (SpecialFunctions.Gamma((dof + 1.0) / 2.0) / SpecialFunctions.Gamma(dof / 2.0)), n.Mean);
 }
예제 #41
0
 public void SetDofFailsWithNonPositiveDoF([Values(-1.0, -0.0, 0.0)] double dof)
 {
     var n = new Chi(1.0);
     Assert.Throws<ArgumentOutOfRangeException>(() => n.DegreesOfFreedom = dof);
 }
예제 #42
0
        public void ValidateMinimum()
        {
            var n = new Chi(1.0);

            Assert.AreEqual(0.0, n.Minimum);
        }
예제 #43
0
 public void ValidateDensity(double dof, double x)
 {
     var n = new Chi(dof);
     Assert.AreEqual<double>((Math.Pow(2.0, 1.0 - dof / 2.0) * Math.Pow(x, dof - 1.0) * Math.Exp(-x * x / 2.0)) / SpecialFunctions.Gamma(dof / 2.0), n.Density(x));
 }
예제 #44
0
 public void ValidateDensityLn(double dof, double x)
 {
     var n = new Chi(dof);
     Assert.AreEqual(((1.0 - (dof / 2.0)) * Math.Log(2.0)) + ((dof - 1.0) * Math.Log(x)) - (x * (x / 2.0)) - SpecialFunctions.GammaLn(dof / 2.0), n.DensityLn(x));
 }
예제 #45
0
        public void ValidateStdDev(double dof)
        {
            var n = new Chi(dof);

            Assert.AreEqual(Math.Sqrt(n.Variance), n.StdDev);
        }
예제 #46
0
 public void ValidateMedian()
 {
     var n = new Chi(1.0);
     var median = n.Median;
 }
예제 #47
0
        public void ValidateMedianThrowsNotSupportedException()
        {
            var n = new Chi(1.0);

            Assert.Throws <NotSupportedException>(() => { var median = n.Median; });
        }
예제 #48
0
 public void ValidateMode([Values(1.0, 2.0, 2.5, 3.0, Double.PositiveInfinity)] double dof)
 {
     var n = new Chi(dof);
     if (dof >= 1)
     {
         Assert.AreEqual(Math.Sqrt(dof - 1), n.Mode);
     }
 }
예제 #49
0
        public void ValidateMaximum()
        {
            var n = new Chi(1.0);

            Assert.AreEqual(Double.PositiveInfinity, n.Maximum);
        }
예제 #50
0
 public void ValidateMedianThrowsNotSupportedException()
 {
     var n = new Chi(1.0);
     Assert.Throws<NotSupportedException>(() => { var median = n.Median; });
 }
예제 #51
0
        public void CanSample()
        {
            var n = new Chi(1.0);

            n.Sample();
        }
예제 #52
0
 public void ValidateMinimum()
 {
     var n = new Chi(1.0);
     Assert.AreEqual(0.0, n.Minimum);
 }
예제 #53
0
 public void ValidateMean([Values(1.0, 2.0, 2.5, 5.0, Double.PositiveInfinity)] double dof)
 {
     var n = new Chi(dof);
     Assert.AreEqual(Math.Sqrt(2) * (SpecialFunctions.Gamma((dof + 1.0) / 2.0) / SpecialFunctions.Gamma(dof / 2.0)), n.Mean);
 }
예제 #54
0
 public void ValidateMaximum()
 {
     var n = new Chi(1.0);
     Assert.AreEqual(Double.PositiveInfinity, n.Maximum);
 }
예제 #55
0
        public void ValidateToString()
        {
            var n = new Chi(1.0);

            Assert.AreEqual("Chi(k = 1)", n.ToString());
        }
예제 #56
0
 public void ValidateVariance([Values(1.0, 2.0, 2.5, 3.0, Double.PositiveInfinity)] double dof)
 {
     var n = new Chi(dof);
     Assert.AreEqual(dof - (n.Mean * n.Mean), n.Variance);
 }
        /// <summary>
        /// Run example
        /// </summary>
        /// <a href="http://en.wikipedia.org/wiki/Chi_distribution">Chi distribution</a>
        public void Run()
        {
            // 1. Initialize the new instance of the Chi distribution class with parameter dof = 1.
            var chi = new Chi(1);

            Console.WriteLine(@"1. Initialize the new instance of the Chi distribution class with parameter DegreesOfFreedom = {0}", chi.DegreesOfFreedom);
            Console.WriteLine();

            // 2. Distributuion properties:
            Console.WriteLine(@"2. {0} distributuion properties:", chi);

            // Cumulative distribution function
            Console.WriteLine(@"{0} - Сumulative distribution at location '0.3'", chi.CumulativeDistribution(0.3).ToString(" #0.00000;-#0.00000"));

            // Probability density
            Console.WriteLine(@"{0} - Probability density at location '0.3'", chi.Density(0.3).ToString(" #0.00000;-#0.00000"));

            // Log probability density
            Console.WriteLine(@"{0} - Log probability density at location '0.3'", chi.DensityLn(0.3).ToString(" #0.00000;-#0.00000"));

            // Entropy
            Console.WriteLine(@"{0} - Entropy", chi.Entropy.ToString(" #0.00000;-#0.00000"));

            // Largest element in the domain
            Console.WriteLine(@"{0} - Largest element in the domain", chi.Maximum.ToString(" #0.00000;-#0.00000"));

            // Smallest element in the domain
            Console.WriteLine(@"{0} - Smallest element in the domain", chi.Minimum.ToString(" #0.00000;-#0.00000"));

            // Mean
            Console.WriteLine(@"{0} - Mean", chi.Mean.ToString(" #0.00000;-#0.00000"));

            // Mode
            Console.WriteLine(@"{0} - Mode", chi.Mode.ToString(" #0.00000;-#0.00000"));

            // Variance
            Console.WriteLine(@"{0} - Variance", chi.Variance.ToString(" #0.00000;-#0.00000"));

            // Standard deviation
            Console.WriteLine(@"{0} - Standard deviation", chi.StdDev.ToString(" #0.00000;-#0.00000"));

            // Skewness
            Console.WriteLine(@"{0} - Skewness", chi.Skewness.ToString(" #0.00000;-#0.00000"));
            Console.WriteLine();

            // 3. Generate 10 samples of the Chi distribution
            Console.WriteLine(@"3. Generate 10 samples of the Chi distribution");
            for (var i = 0; i < 10; i++)
            {
                Console.Write(chi.Sample().ToString("N05") + @" ");
            }

            Console.WriteLine();
            Console.WriteLine();

            // 4. Generate 100000 samples of the Chi(1) distribution and display histogram
            Console.WriteLine(@"4. Generate 100000 samples of the Chi(1) distribution and display histogram");
            var data = new double[100000];

            for (var i = 0; i < data.Length; i++)
            {
                data[i] = chi.Sample();
            }

            ConsoleHelper.DisplayHistogram(data);
            Console.WriteLine();

            // 5. Generate 100000 samples of the Chi(2) distribution and display histogram
            Console.WriteLine(@"5. Generate 100000 samples of the Chi(2) distribution and display histogram");
            chi.DegreesOfFreedom = 2;
            for (var i = 0; i < data.Length; i++)
            {
                data[i] = chi.Sample();
            }

            ConsoleHelper.DisplayHistogram(data);
            Console.WriteLine();

            // 6. Generate 100000 samples of the Chi(5) distribution and display histogram
            Console.WriteLine(@"6. Generate 100000 samples of the Chi(5) distribution and display histogram");
            chi.DegreesOfFreedom = 5;
            for (var i = 0; i < data.Length; i++)
            {
                data[i] = chi.Sample();
            }

            ConsoleHelper.DisplayHistogram(data);
        }
예제 #58
0
 public void ValidateStdDev([Values(1.0, 2.0, 2.5, 3.0, Double.PositiveInfinity)] double dof)
 {
     var n = new Chi(dof);
     Assert.AreEqual(Math.Sqrt(n.Variance), n.StdDev);
 }