public void ValidateDensityLn( [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double shape, [Values(0.1, 1.0, 2.0, 2.1, 10.0, 12.0, Double.PositiveInfinity)] double x) { var n = new Pareto(scale, shape); Assert.AreEqual(Math.Log(n.Density(x)), n.DensityLn(x)); }
public void ValidateDensity(double scale, double shape, double x, double expected) { var dist = new Pareto(scale, shape); Assert.AreEqual(expected, dist.Density(x), 1e-12); Assert.AreEqual(expected, Pareto.PDF(scale, shape, x), 1e-12); Assert.AreEqual(Math.Log(expected), dist.DensityLn(x), 1e-12); Assert.AreEqual(Math.Log(expected), Pareto.PDFLn(scale, shape, x), 1e-12); }
public void ValidateDensityLn(double scale, double shape, double x) { var n = new Pareto(scale, shape); Assert.AreEqual(Math.Log(n.Density(x)), n.DensityLn(x)); }
public void ValidateDensity(double scale, double shape, double x) { var n = new Pareto(scale, shape); Assert.AreEqual(shape * Math.Pow(scale, shape) / Math.Pow(x, shape + 1.0), n.Density(x)); }
/// <summary> /// Run example /// </summary> /// <a href="http://en.wikipedia.org/wiki/Pareto_distribution">Pareto distribution</a> public void Run() { // 1. Initialize the new instance of the Pareto distribution class with parameters Shape = 3, Scale = 1 var pareto = new Pareto(1, 3); Console.WriteLine(@"1. Initialize the new instance of the Pareto distribution class with parameters Shape = {0}, Scale = {1}", pareto.Shape, pareto.Scale); Console.WriteLine(); // 2. Distributuion properties: Console.WriteLine(@"2. {0} distributuion properties:", pareto); // Cumulative distribution function Console.WriteLine(@"{0} - Сumulative distribution at location '0.3'", pareto.CumulativeDistribution(0.3).ToString(" #0.00000;-#0.00000")); // Probability density Console.WriteLine(@"{0} - Probability density at location '0.3'", pareto.Density(0.3).ToString(" #0.00000;-#0.00000")); // Log probability density Console.WriteLine(@"{0} - Log probability density at location '0.3'", pareto.DensityLn(0.3).ToString(" #0.00000;-#0.00000")); // Entropy Console.WriteLine(@"{0} - Entropy", pareto.Entropy.ToString(" #0.00000;-#0.00000")); // Largest element in the domain Console.WriteLine(@"{0} - Largest element in the domain", pareto.Maximum.ToString(" #0.00000;-#0.00000")); // Smallest element in the domain Console.WriteLine(@"{0} - Smallest element in the domain", pareto.Minimum.ToString(" #0.00000;-#0.00000")); // Mean Console.WriteLine(@"{0} - Mean", pareto.Mean.ToString(" #0.00000;-#0.00000")); // Median Console.WriteLine(@"{0} - Median", pareto.Median.ToString(" #0.00000;-#0.00000")); // Mode Console.WriteLine(@"{0} - Mode", pareto.Mode.ToString(" #0.00000;-#0.00000")); // Variance Console.WriteLine(@"{0} - Variance", pareto.Variance.ToString(" #0.00000;-#0.00000")); // Standard deviation Console.WriteLine(@"{0} - Standard deviation", pareto.StdDev.ToString(" #0.00000;-#0.00000")); // Skewness Console.WriteLine(@"{0} - Skewness", pareto.Skewness.ToString(" #0.00000;-#0.00000")); Console.WriteLine(); // 3. Generate 10 samples of the Pareto distribution Console.WriteLine(@"3. Generate 10 samples of the Pareto distribution"); for (var i = 0; i < 10; i++) { Console.Write(pareto.Sample().ToString("N05") + @" "); } Console.WriteLine(); Console.WriteLine(); // 4. Generate 100000 samples of the Pareto(1, 3) distribution and display histogram Console.WriteLine(@"4. Generate 100000 samples of the Pareto(1, 3) distribution and display histogram"); var data = new double[100000]; for (var i = 0; i < data.Length; i++) { data[i] = pareto.Sample(); } ConsoleHelper.DisplayHistogram(data); Console.WriteLine(); // 5. Generate 100000 samples of the Pareto(1, 1) distribution and display histogram Console.WriteLine(@"5. Generate 100000 samples of the Pareto(1, 1) distribution and display histogram"); pareto.Shape = 1; for (var i = 0; i < data.Length; i++) { data[i] = pareto.Sample(); } ConsoleHelper.DisplayHistogram(data); Console.WriteLine(); // 6. Generate 100000 samples of the Pareto(10, 5) distribution and display histogram Console.WriteLine(@"6. Generate 100000 samples of the Pareto(10, 50) distribution and display histogram"); pareto.Shape = 50; pareto.Scale = 10; for (var i = 0; i < data.Length; i++) { data[i] = pareto.Sample(); } ConsoleHelper.DisplayHistogram(data); }
public void ValidateDensityLn(double scale, double shape, double x) { var n = new Pareto(scale, shape); Assert.AreEqual <double>(Math.Log(n.Density(x)), n.DensityLn(x)); }
public void ValidateDensity(double scale, double shape, double x) { var n = new Pareto(scale, shape); Assert.AreEqual <double>(shape * Math.Pow(scale, shape) / Math.Pow(x, shape + 1.0), n.Density(x)); }
public void ValidateDensity( [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double shape, [Values(0.1, 1.0, 2.0, 2.1, 10.0, 12.0, Double.PositiveInfinity)] double x) { var n = new Pareto(scale, shape); Assert.AreEqual(shape * Math.Pow(scale, shape) / Math.Pow(x, shape + 1.0), n.Density(x)); }