Exemplo n.º 1
0
        public void CanSampleSequence()
        {
            var n   = new Erlang(1, 2.0);
            var ied = n.Samples();

            ied.Take(5).ToArray();
        }
Exemplo n.º 2
0
 public void CanSampleSequence()
 {
     var n = new Erlang(1, 2.0);
     var ied = n.Samples();
     ied.Take(5).ToArray();
 }
Exemplo n.º 3
0
        /// <summary>
        /// Run example
        /// </summary>
        /// <a href="http://en.wikipedia.org/wiki/Erlang_distribution">Erlang distribution</a>
        public void Run()
        {
            // 1. Initialize the new instance of the Erlang distribution class with parameters Shape = 1, Scale = 2.
            var erlang = new Erlang(1, 2.0);

            Console.WriteLine(@"1. Initialize the new instance of the Erlang distribution class with parameters Shape = {0}, Scale = {1}", erlang.Shape, erlang.Scale);
            Console.WriteLine();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            Erlang.Samples(data, 1, 2.0);
            ConsoleHelper.DisplayHistogram(data);
            Console.WriteLine();

            // 5. Generate 100000 samples of the Erlang(3, 2.0) distribution and display histogram
            Console.WriteLine(@"5. Generate 100000 samples of the Erlang(3, 2.0) distribution and display histogram");
            Erlang.Samples(data, 3, 2.0);
            ConsoleHelper.DisplayHistogram(data);
            Console.WriteLine();

            // 6. Generate 100000 samples of the Erlang(9, 0.5) distribution and display histogram
            Console.WriteLine(@"6. Generate 100000 samples of the Erlang(9, 0.5) distribution and display histogram");
            Erlang.Samples(data, 9, 0.5);
            ConsoleHelper.DisplayHistogram(data);
        }