public void FitTest1() { double[] values = { 0, 1, 2, 4, 2, 3, 5, 7, 4, 3, 2, 1, 4, }; var exp = new ExponentialDistribution(); exp.Fit(values); string actual; var cultureInfo = CultureInfo.GetCultureInfo("fr-FR"); #if NETCORE System.Globalization.CultureInfo.DefaultThreadCurrentCulture = cultureInfo; System.Globalization.CultureInfo.DefaultThreadCurrentUICulture = cultureInfo; #else Thread.CurrentThread.CurrentCulture = cultureInfo; #endif actual = exp.ToString("G3", CultureInfo.InvariantCulture); Assert.AreEqual("Exp(x; λ = 0.342)", actual); actual = exp.ToString("G3"); Assert.AreEqual("Exp(x; λ = 0,342)", actual); actual = exp.ToString(CultureInfo.InvariantCulture); Assert.AreEqual("Exp(x; λ = 0.342105263157895)", actual); actual = exp.ToString(); Assert.AreEqual("Exp(x; λ = 0,342105263157895)", actual); }
public void FitTest1() { double[] values = { 0, 1, 2, 4, 2, 3, 5, 7, 4, 3, 2, 1, 4, }; var exp = new ExponentialDistribution(); exp.Fit(values); string actual; Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("fr-FR"); actual = exp.ToString("G3", CultureInfo.InvariantCulture); Assert.AreEqual("Exp(x; λ = 0.342)", actual); actual = exp.ToString("G3"); Assert.AreEqual("Exp(x; λ = 0,342)", actual); actual = exp.ToString(CultureInfo.InvariantCulture); Assert.AreEqual("Exp(x; λ = 0.342105263157895)", actual); actual = exp.ToString(); Assert.AreEqual("Exp(x; λ = 0,342105263157895)", actual); }
public void ConstructorTest2() { var exp = new ExponentialDistribution(rate: 0.42); double mean = exp.Mean; // 2.3809523809523809 double median = exp.Median; // 1.6503504299046317 double var = exp.Variance; // 5.6689342403628125 double cdf = exp.DistributionFunction(x: 0.27); // 0.10720652870550407 double pdf = exp.ProbabilityDensityFunction(x: 0.27); // 0.3749732579436883 double lpdf = exp.LogProbabilityDensityFunction(x: 0.27); // -0.98090056770472311 double ccdf = exp.ComplementaryDistributionFunction(x: 0.27); // 0.89279347129449593 double icdf = exp.InverseDistributionFunction(p: cdf); // 0.27 double hf = exp.HazardFunction(x: 0.27); // 0.42 double chf = exp.CumulativeHazardFunction(x: 0.27); // 0.1134 string str = exp.ToString(CultureInfo.InvariantCulture); // Exp(x; λ = 0.42) Assert.AreEqual(2.3809523809523809, mean); Assert.AreEqual(1.6503504299046317, median); Assert.AreEqual(5.6689342403628125, var); Assert.AreEqual(0.1134, chf); Assert.AreEqual(0.10720652870550407, cdf); Assert.AreEqual(0.3749732579436883, pdf); Assert.AreEqual(-0.98090056770472311, lpdf); Assert.AreEqual(0.42, hf); Assert.AreEqual(0.89279347129449593, ccdf); Assert.AreEqual(0.27, icdf); Assert.AreEqual("Exp(x; λ = 0.42)", str); }
public void ConstructorTest2() { var exp = new ExponentialDistribution(rate: 0.42); double mean = exp.Mean; // 2.3809523809523809 double median = exp.Median; // 1.6503504299046317 double var = exp.Variance; // 5.6689342403628125 double cdf = exp.DistributionFunction(x: 0.27); // 0.10720652870550407 double pdf = exp.ProbabilityDensityFunction(x: 0.27); // 0.3749732579436883 double lpdf = exp.LogProbabilityDensityFunction(x: 0.27); // -0.98090056770472311 double ccdf = exp.ComplementaryDistributionFunction(x: 0.27); // 0.89279347129449593 double icdf = exp.InverseDistributionFunction(p: cdf); // 0.27 double hf = exp.HazardFunction(x: 0.27); // 0.42 double chf = exp.CumulativeHazardFunction(x: 0.27); // 0.1134 string str = exp.ToString(CultureInfo.InvariantCulture); // Exp(x; λ = 0.42) Assert.AreEqual(2.3809523809523809, mean); Assert.AreEqual(1.6503504299046317, median); Assert.AreEqual(5.6689342403628125, var); Assert.AreEqual(0.1134, chf); Assert.AreEqual(0.10720652870550407, cdf); Assert.AreEqual(0.3749732579436883, pdf); Assert.AreEqual(-0.98090056770472311, lpdf); Assert.AreEqual(0.42, hf); Assert.AreEqual(0.89279347129449593, ccdf); Assert.AreEqual(0.27, icdf); Assert.AreEqual("Exp(x; λ = 0.42)", str); }
public void ConstructorTest2() { var exp = new ExponentialDistribution(rate: 0.42); double mean = exp.Mean; // 2.3809523809523809 double median = exp.Median; // 1.6503504299046317 double var = exp.Variance; // 5.6689342403628125 double mode = exp.Mode; // 0.0 double cdf = exp.DistributionFunction(x: 0.27); // 0.10720652870550407 double pdf = exp.ProbabilityDensityFunction(x: 0.27); // 0.3749732579436883 double lpdf = exp.LogProbabilityDensityFunction(x: 0.27); // -0.98090056770472311 double ccdf = exp.ComplementaryDistributionFunction(x: 0.27); // 0.89279347129449593 double icdf = exp.InverseDistributionFunction(p: cdf); // 0.27 double hf = exp.HazardFunction(x: 0.27); // 0.42 double chf = exp.CumulativeHazardFunction(x: 0.27); // 0.1134 string str = exp.ToString(CultureInfo.InvariantCulture); // Exp(x; λ = 0.42) Assert.AreEqual(2.3809523809523809, mean); Assert.AreEqual(1.6503504299046317, median); Assert.AreEqual(0.0, mode); Assert.AreEqual(5.6689342403628125, var); Assert.AreEqual(0.1134, chf); Assert.AreEqual(0.10720652870550407, cdf); Assert.AreEqual(0.3749732579436883, pdf); Assert.AreEqual(-0.98090056770472311, lpdf); Assert.AreEqual(0.42, hf); Assert.AreEqual(0.89279347129449593, ccdf); Assert.AreEqual(0.27, icdf); Assert.AreEqual("Exp(x; λ = 0.42)", str); var range1 = exp.GetRange(0.95); var range2 = exp.GetRange(0.99); var range3 = exp.GetRange(0.01); Assert.AreEqual(0.12212689139892995, range1.Min); Assert.AreEqual(7.1326958894142622, range1.Max); Assert.AreEqual(0.023929371079765359, range2.Min); Assert.AreEqual(10.964690919019265, range2.Max); Assert.AreEqual(0.023929371079765359, range3.Min); Assert.AreEqual(10.964690919019265, range3.Max); }
public void ConstructorTest2() { var exp = new ExponentialDistribution(rate: 0.42); double mean = exp.Mean; // 2.3809523809523809 double median = exp.Median; // 1.6503504299046317 double var = exp.Variance; // 5.6689342403628125 double mode = exp.Mode; // 0.0 double cdf = exp.DistributionFunction(x: 0.27); // 0.10720652870550407 double pdf = exp.ProbabilityDensityFunction(x: 0.27); // 0.3749732579436883 double lpdf = exp.LogProbabilityDensityFunction(x: 0.27); // -0.98090056770472311 double ccdf = exp.ComplementaryDistributionFunction(x: 0.27); // 0.89279347129449593 double icdf = exp.InverseDistributionFunction(p: cdf); // 0.27 double hf = exp.HazardFunction(x: 0.27); // 0.42 double chf = exp.CumulativeHazardFunction(x: 0.27); // 0.1134 string str = exp.ToString(CultureInfo.InvariantCulture); // Exp(x; λ = 0.42) Assert.AreEqual(2.3809523809523809, mean); Assert.AreEqual(1.6503504299046317, median); Assert.AreEqual(0.0, mode); Assert.AreEqual(5.6689342403628125, var); Assert.AreEqual(0.1134, chf); Assert.AreEqual(0.10720652870550407, cdf); Assert.AreEqual(0.3749732579436883, pdf); Assert.AreEqual(-0.98090056770472311, lpdf); Assert.AreEqual(0.42, hf); Assert.AreEqual(0.89279347129449593, ccdf); Assert.AreEqual(0.27, icdf); Assert.AreEqual("Exp(x; λ = 0.42)", str); var range1 = exp.GetRange(0.95); var range2 = exp.GetRange(0.99); var range3 = exp.GetRange(0.01); Assert.AreEqual(0.12212689139892995, range1.Min); Assert.AreEqual(7.1326958894142622, range1.Max); Assert.AreEqual(0.023929371079765359, range2.Min); Assert.AreEqual(10.964690919019265, range2.Max); Assert.AreEqual(0.023929371079765359, range3.Min); Assert.AreEqual(10.964690919019265, range3.Max); }
public void FitTest1() { double[] values = { 0, 1, 2, 4, 2, 3, 5, 7, 4, 3, 2, 1, 4, }; var exp = new ExponentialDistribution(); exp.Fit(values); string actual; Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("fr-FR"); actual = exp.ToString("G3", CultureInfo.InvariantCulture); Assert.AreEqual("Exp(x; λ = 0.342)", actual); actual = exp.ToString("G3"); Assert.AreEqual("Exp(x; λ = 0,342)", actual); actual = exp.ToString(CultureInfo.InvariantCulture); Assert.AreEqual("Exp(x; λ = 0.342105263157895)", actual); actual = exp.ToString(); Assert.AreEqual("Exp(x; λ = 0,342105263157895)", actual); }