public void ConstructorTest() { var F = new FDistribution(degrees1: 8, degrees2: 5); double mean = F.Mean; // 1.6666666666666667 double median = F.Median; // 1.0545096252132447 double var = F.Variance; // 7.6388888888888893 double cdf = F.DistributionFunction(x: 0.27); // 0.049463408057268315 double pdf = F.ProbabilityDensityFunction(x: 0.27); // 0.45120469723580559 double lpdf = F.LogProbabilityDensityFunction(x: 0.27); // -0.79583416831212883 double ccdf = F.ComplementaryDistributionFunction(x: 0.27); // 0.95053659194273166 double icdf = F.InverseDistributionFunction(p: cdf); // 0.27 double hf = F.HazardFunction(x: 0.27); // 0.47468419528555084 double chf = F.CumulativeHazardFunction(x: 0.27); // 0.050728620222091653 string str = F.ToString(CultureInfo.InvariantCulture); // F(x; df1 = 8, df2 = 5) Assert.AreEqual(1.6666666666666667, mean); Assert.AreEqual(1.0545096252132447, median); Assert.AreEqual(7.6388888888888893, var); Assert.AreEqual(0.050728620222091653, chf); Assert.AreEqual(0.049463408057268315, cdf); Assert.AreEqual(0.45120469723580559, pdf); Assert.AreEqual(-0.79583416831212883, lpdf); Assert.AreEqual(0.47468419528555084, hf); Assert.AreEqual(0.95053659194273166, ccdf); Assert.AreEqual(0.27, icdf); Assert.AreEqual("F(x; df1 = 8, df2 = 5)", str); }
public void ProbabilityDistributionFunctionTest() { FDistribution f = new FDistribution(2, 3); double expected = 0.487139289628747; double actual = f.ProbabilityDensityFunction(0.5); Assert.AreEqual(expected, actual, 1e-6); }
public void ConstructorTest() { var F = new FDistribution(degrees1: 8, degrees2: 5); double mean = F.Mean; // 1.6666666666666667 double median = F.Median; // 1.0545096252132447 double var = F.Variance; // 7.6388888888888893 double mode = F.Mode; // 0.5357142857142857 double cdf = F.DistributionFunction(x: 0.27); // 0.049463408057268315 double pdf = F.ProbabilityDensityFunction(x: 0.27); // 0.45120469723580559 double lpdf = F.LogProbabilityDensityFunction(x: 0.27); // -0.79583416831212883 double ccdf = F.ComplementaryDistributionFunction(x: 0.27); // 0.95053659194273166 double icdf = F.InverseDistributionFunction(p: cdf); // 0.27 double hf = F.HazardFunction(x: 0.27); // 0.47468419528555084 double chf = F.CumulativeHazardFunction(x: 0.27); // 0.050728620222091653 string str = F.ToString(CultureInfo.InvariantCulture); // F(x; df1 = 8, df2 = 5) Assert.AreEqual(0, F.Support.Min); Assert.AreEqual(double.PositiveInfinity, F.Support.Max); Assert.AreEqual(F.InverseDistributionFunction(0), F.Support.Min); Assert.AreEqual(F.InverseDistributionFunction(1), F.Support.Max); Assert.AreEqual(1.6666666666666667, mean); Assert.AreEqual(1.0545096252132447, median); Assert.AreEqual(7.6388888888888893, var); Assert.AreEqual(0.5357142857142857, mode); Assert.AreEqual(0.050728620222091653, chf); Assert.AreEqual(0.049463408057268315, cdf); Assert.AreEqual(0.45120469723580559, pdf); Assert.AreEqual(-0.79583416831212883, lpdf); Assert.AreEqual(0.47468419528555084, hf); Assert.AreEqual(0.95053659194273166, ccdf); Assert.AreEqual(0.27, icdf); Assert.AreEqual("F(x; df1 = 8, df2 = 5)", str); var range1 = F.GetRange(0.95); var range2 = F.GetRange(0.99); var range3 = F.GetRange(0.01); Assert.AreEqual(0.27118653875813753, range1.Min); Assert.AreEqual(4.8183195356568689, range1.Max); Assert.AreEqual(0.15078805233761733, range2.Min); Assert.AreEqual(10.289311046135927, range2.Max); Assert.AreEqual(0.1507880523376173, range3.Min); Assert.AreEqual(10.289311046135927, range3.Max); }
public void Confirm_BetPrimeDistribution_Relative_to_F_Distribution() { double alpha = 4.0d; double beta = 6.0d; FDistribution fdist = new FDistribution((int)alpha * 2, (int)beta * 2); double fMean = fdist.Mean; double fPdf = (beta / alpha) * fdist.ProbabilityDensityFunction(4.0d); double fCdf = fdist.DistributionFunction(4.0d); var betaPrimeDist = new BetaPrimeDistribution(alpha, beta); double bpMean = (beta / alpha) * betaPrimeDist.Mean; double bpPdf = betaPrimeDist.ProbabilityDensityFunction((alpha / beta) * 4.0d); double bpCdf = betaPrimeDist.DistributionFunction((alpha / beta) * 4.0d); Assert.AreEqual(fMean, bpMean, 0.00000001, "mean should be equal"); Assert.AreEqual(fPdf, bpPdf, 0.00000001, "probability density should be equal"); Assert.AreEqual(fCdf, bpCdf, 0.00000001, "cumulative distribution should be equal"); //Beta Prime distribution is a scaled version of Pearson Type VI, which itself is scale of F distribution }
public void ProbabilityDistributionFunctionTest2() { FDistribution f = new FDistribution(2, 2); Assert.AreEqual(f.ProbabilityDensityFunction(1), 0.2500, 1e-4); Assert.AreEqual(f.ProbabilityDensityFunction(2), 0.1111, 1e-4); Assert.AreEqual(f.ProbabilityDensityFunction(3), 0.0625, 1e-4); Assert.AreEqual(f.ProbabilityDensityFunction(4), 0.0400, 1e-4); Assert.AreEqual(f.ProbabilityDensityFunction(5), 0.0278, 1e-4); Assert.AreEqual(f.ProbabilityDensityFunction(6), 0.0204, 1e-4); Assert.AreEqual(new FDistribution(5, 5).ProbabilityDensityFunction(3), 0.0689, 1e-4); Assert.AreEqual(new FDistribution(6, 6).ProbabilityDensityFunction(3), 0.0659, 1e-4); Assert.AreEqual(new FDistribution(7, 7).ProbabilityDensityFunction(3), 0.0620, 1e-4); Assert.AreEqual(new FDistribution(8, 8).ProbabilityDensityFunction(3), 0.0577, 1e-4); Assert.AreEqual(new FDistribution(9, 9).ProbabilityDensityFunction(3), 0.0532, 1e-4); Assert.AreEqual(new FDistribution(10, 10).ProbabilityDensityFunction(3), 0.0487, 1e-4); }
public void LogProbabilityDistributionFunctionTest2() { FDistribution f = new FDistribution(2, 2); double actual; double expected; double x; for (int i = 1; i <= 6; i++) { x = i; actual = f.LogProbabilityDensityFunction(x); expected = System.Math.Log(f.ProbabilityDensityFunction(x)); Assert.AreEqual(expected, actual, 1e-10); } for (int i = 5; i <= 10; i++) { f = new FDistribution(i, i); x = 3; actual = f.LogProbabilityDensityFunction(x); expected = System.Math.Log(f.ProbabilityDensityFunction(x)); Assert.AreEqual(expected, actual, 1e-10); } }