コード例 #1
0
ファイル: RayleighTests.cs プロジェクト: wibble82/mmbot
        public void ValidateMedian([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale)
        {
            var n = new Rayleigh(scale);

            Assert.AreEqual(scale * Math.Sqrt(Math.Log(4.0)), n.Median);
        }
コード例 #2
0
 public void ValidateMode([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale)
 {
     var n = new Rayleigh(scale);
     Assert.AreEqual(scale, n.Mode);
 }
コード例 #3
0
 public void ValidateVariance([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale)
 {
     var n = new Rayleigh(scale);
     Assert.AreEqual((2.0 - Constants.PiOver2) * scale * scale, n.Variance);
 }
コード例 #4
0
 public void SetScaleFailsWithNegativeScale([Values(-0.0, 0.0, -1.0, Double.NegativeInfinity, Double.NaN)] double scale)
 {
     var n = new Rayleigh(1.0);
     Assert.Throws<ArgumentOutOfRangeException>(() => n.Scale = scale);
 }
コード例 #5
0
 public void ValidateEntropy([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale)
 {
     var n = new Rayleigh(scale);
     Assert.AreEqual(1.0 + Math.Log(scale / Math.Sqrt(2)) + (Constants.EulerMascheroni / 2.0), n.Entropy);
 }
コード例 #6
0
        public void ValidateMaximum(double scale)
        {
            var n = new Rayleigh(1.0);

            Assert.AreEqual(Double.PositiveInfinity, n.Maximum);
        }
コード例 #7
0
        public void ValidateCumulativeDistribution(double scale, double x)
        {
            var n = new Rayleigh(scale);

            Assert.AreEqual(1.0 - Math.Exp(-x * x / (2.0 * scale * scale)), n.CumulativeDistribution(x));
        }
コード例 #8
0
ファイル: RayleighTests.cs プロジェクト: wibble82/mmbot
        public void SetScaleFailsWithNegativeScale([Values(-0.0, 0.0, -1.0, Double.NegativeInfinity, Double.NaN)] double scale)
        {
            var n = new Rayleigh(1.0);

            Assert.Throws <ArgumentOutOfRangeException>(() => n.Scale = scale);
        }
コード例 #9
0
 public void ValidateDensityLn(double scale, double x)
 {
     var n = new Rayleigh(scale);
     Assert.AreEqual<double>(Math.Log(x / (scale * scale)) - x * x / (2.0 * scale * scale), n.DensityLn(x));
 }
コード例 #10
0
ファイル: RayleighTests.cs プロジェクト: wibble82/mmbot
        public void ValidateCumulativeDistribution([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double x)
        {
            var n = new Rayleigh(scale);

            Assert.AreEqual(1.0 - Math.Exp(-x * x / (2.0 * scale * scale)), n.CumulativeDistribution(x));
        }
コード例 #11
0
ファイル: RayleighTests.cs プロジェクト: wibble82/mmbot
        public void CanCreateRayleigh([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale)
        {
            var n = new Rayleigh(scale);

            Assert.AreEqual(scale, n.Scale);
        }
コード例 #12
0
ファイル: RayleighTests.cs プロジェクト: wibble82/mmbot
        public void ValidateDensityLn([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double x)
        {
            var n = new Rayleigh(scale);

            Assert.AreEqual(Math.Log(x / (scale * scale)) - (x * (x / (2.0 * (scale * scale)))), n.DensityLn(x));
        }
コード例 #13
0
ファイル: RayleighTests.cs プロジェクト: wibble82/mmbot
        public void ValidateDensity([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double x)
        {
            var n = new Rayleigh(scale);

            Assert.AreEqual((x / (scale * scale)) * Math.Exp(-x * x / (2.0 * scale * scale)), n.Density(x));
        }
コード例 #14
0
ファイル: RayleighTests.cs プロジェクト: wibble82/mmbot
        public void ValidateMaximum([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale)
        {
            var n = new Rayleigh(1.0);

            Assert.AreEqual(Double.PositiveInfinity, n.Maximum);
        }
コード例 #15
0
        public void ValidateSkewness(double scale, double skn)
        {
            var n = new Rayleigh(scale);

            AssertHelpers.AlmostEqual(skn, n.Skewness, 17);
        }
コード例 #16
0
 public void ValidateEntropy(double scale)
 {
     var n = new Rayleigh(scale);
     Assert.AreEqual<double>(1.0 + Math.Log(scale / Math.Sqrt(2)) + Constants.EulerMascheroni / 2.0, n.Entropy);
 }
コード例 #17
0
        public void ValidateMedian(double scale)
        {
            var n = new Rayleigh(scale);

            Assert.AreEqual(scale * Math.Sqrt(Math.Log(4.0)), n.Median);
        }
コード例 #18
0
 public void ValidateMaximum(double scale)
 {
     var n = new Rayleigh(1.0);
     Assert.AreEqual<double>(Double.PositiveInfinity, n.Maximum);
 }
コード例 #19
0
        public void ValidateDensityLn(double scale, double x)
        {
            var n = new Rayleigh(scale);

            Assert.AreEqual(Math.Log(x / (scale * scale)) - (x * (x / (2.0 * (scale * scale)))), n.DensityLn(x));
        }
コード例 #20
0
 public void ValidateMean(double scale)
 {
     var n = new Rayleigh(scale);
     Assert.AreEqual(scale * Math.Sqrt(Constants.PiOver2), n.Mean);
 }
コード例 #21
0
        public void ValidateToString()
        {
            var n = new Rayleigh(2.0);

            Assert.AreEqual("Rayleigh(Scale = 2)", n.ToString());
        }
コード例 #22
0
 public void ValidateMedian(double scale)
 {
     var n = new Rayleigh(scale);
     Assert.AreEqual<double>(scale * Math.Sqrt(Math.Log(4.0)), n.Median);
 }
コード例 #23
0
 public void ValidateDensity([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double x)
 {
     var n = new Rayleigh(scale);
     Assert.AreEqual((x / (scale * scale)) * Math.Exp(-x * x / (2.0 * scale * scale)), n.Density(x));
 }
コード例 #24
0
 public void ValidateMinimum(double scale)
 {
     var n = new Rayleigh(scale);
     Assert.AreEqual<double>(0.0, n.Minimum);
 }
コード例 #25
0
 public void ValidateMean([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale)
 {
     var n = new Rayleigh(scale);
     Assert.AreEqual(scale * Math.Sqrt(Constants.PiOver2), n.Mean);
 }
コード例 #26
0
 public void ValidateMode(double scale)
 {
     var n = new Rayleigh(scale);
     Assert.AreEqual<double>(scale, n.Mode);
 }
コード例 #27
0
 public void ValidateStdDev([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale)
 {
     var n = new Rayleigh(scale);
     Assert.AreEqual(Math.Sqrt(2.0 - Constants.PiOver2) * scale, n.StdDev);
 }
コード例 #28
0
 public void ValidateSkewness(double scale, double skn)
 {
     var n = new Rayleigh(scale);
     AssertHelpers.AlmostEqual(skn, n.Skewness, 17);
 }
コード例 #29
0
 public void CanSample()
 {
     var n = new Rayleigh(1.0);
     n.Sample();
 }
コード例 #30
0
 public void ValidateStdDev(double scale)
 {
     var n = new Rayleigh(scale);
     Assert.AreEqual<double>(Math.Sqrt(2.0 - Constants.PiOver2) * scale, n.StdDev);
 }
コード例 #31
0
        public void ValidateEntropy(double scale)
        {
            var n = new Rayleigh(scale);

            Assert.AreEqual(1.0 + Math.Log(scale / Math.Sqrt(2)) + (Constants.EulerMascheroni / 2.0), n.Entropy);
        }
コード例 #32
0
 public void ValidateVariance(double scale)
 {
     var n = new Rayleigh(scale);
     Assert.AreEqual<double>((2.0 - Constants.PiOver2) * scale * scale, n.Variance);
 }
コード例 #33
0
        public void ValidateMode(double scale)
        {
            var n = new Rayleigh(scale);

            Assert.AreEqual(scale, n.Mode);
        }
コード例 #34
0
 public void CanCreateRayleigh(double scale)
 {
     var n = new Rayleigh(scale);
     Assert.AreEqual<double>(scale, n.Scale);
 }
コード例 #35
0
        public void ValidateMinimum(double scale)
        {
            var n = new Rayleigh(scale);

            Assert.AreEqual(0.0, n.Minimum);
        }
コード例 #36
0
 public void CanSetScale(double scale)
 {
     var n = new Rayleigh(1.0);
     n.Scale = scale;
 }
コード例 #37
0
        public void ValidateDensity(double scale, double x)
        {
            var n = new Rayleigh(scale);

            Assert.AreEqual((x / (scale * scale)) * Math.Exp(-x * x / (2.0 * scale * scale)), n.Density(x));
        }
コード例 #38
0
 public void RayleighCreateFailsWithBadParameters(double scale)
 {
     var n = new Rayleigh(scale);
 }
コード例 #39
0
        public void CanSample()
        {
            var n = new Rayleigh(1.0);

            n.Sample();
        }
コード例 #40
0
 public void SetScaleFailsWithNegativeScale(double scale)
 {
     var n = new Rayleigh(scale);
     n.Scale = scale;
 }
コード例 #41
0
        public void CanCreateRayleigh(double scale)
        {
            var n = new Rayleigh(scale);

            Assert.AreEqual(scale, n.Scale);
        }
コード例 #42
0
        /// <summary>
        /// Run example
        /// </summary>
        /// <a href="http://en.wikipedia.org/wiki/Rayleigh_distribution">Rayleigh distribution</a>
        public void Run()
        {
            // 1. Initialize the new instance of the Rayleigh distribution class with parameter Scale = 1.
            var rayleigh = new Rayleigh(1);

            Console.WriteLine(@"1. Initialize the new instance of the Rayleigh distribution class with parameter Scale = {0}", rayleigh.Scale);
            Console.WriteLine();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            Rayleigh.Samples(data, 1.0);
            ConsoleHelper.DisplayHistogram(data);
            Console.WriteLine();

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

            // 6. Generate 100000 samples of the Rayleigh(0.5) distribution and display histogram
            Console.WriteLine(@"6. Generate 100000 samples of the Rayleigh(0.5) distribution and display histogram");
            Rayleigh.Samples(data, 0.5);
            ConsoleHelper.DisplayHistogram(data);
        }
コード例 #43
0
        public void SetScaleFailsWithNegativeScale(double scale)
        {
            var n = new Rayleigh(1.0);

            Assert.Throws <ArgumentOutOfRangeException>(() => n.Scale = scale);
        }
コード例 #44
0
        private void ModelDFE()
        {
            ListView_TableParametersDFE.Items.Clear();

            var listX0    = new List <int>();
            var listX1    = new List <int>();
            var listX2    = new List <int>();
            var listX3    = new List <int>();
            var listX4    = new List <int>();
            var listX12   = new List <int>();
            var listX13   = new List <int>();
            var listX14   = new List <int>();
            var listX23   = new List <int>();
            var listX24   = new List <int>();
            var listX34   = new List <int>();
            var listX123  = new List <int>();
            var listX124  = new List <int>();
            var listX134  = new List <int>();
            var listX234  = new List <int>();
            var listX1234 = new List <int>();
            var listY     = new List <double>();
            var listYl    = new List <double>();
            var listYcn   = new List <double>();

            for (int i = 1; i <= countAllExperiments / 2; ++i)
            {
                n_DFE = i;
                int x0 = 1;
                listX0.Add(x0);

                int x1 = i % 2 == 0 ? 1 : -1;
                listX1.Add(x1);

                int x2 = (i - 1) / 2 % 2 == 0 ? -1 : 1;
                listX2.Add(x2);

                int x3 = (i - 1) / 4 % 2 == 0 ? -1 : 1;
                listX3.Add(x3);

                int x4 = x1 * x2 * x3;
                listX4.Add(x4);

                int x12 = x1 * x2;
                listX12.Add(x12);

                int x13 = x1 * x3;
                listX13.Add(x13);

                int x14 = x1 * x4;
                listX14.Add(x14);

                int x23 = x2 * x3;
                listX23.Add(x23);

                int x24 = x2 * x4;
                listX24.Add(x24);

                int x34 = x3 * x4;
                listX34.Add(x34);

                int x123 = x1 * x2 * x3;
                listX123.Add(x123);

                int x124 = x1 * x2 * x4;
                listX124.Add(x124);

                int x134 = x1 * x3 * x4;
                listX134.Add(x134);

                int x234 = x2 * x3 * x4;
                listX234.Add(x234);

                int x1234 = x1 * x2 * x3 * x4;
                listX1234.Add(x1234);

                double lambdaComing1     = ConvertFactorToValue(minLambdaComing1, maxLambdaComing1, x1);
                double lambdaComing2     = ConvertFactorToValue(minLambdaComing2, maxLambdaComing2, x2);
                double lambdaProcessing1 = ConvertFactorToValue(minLambdaProcessing1, maxLambdaProcessing1, x3);
                double lambdaProcessing2 = ConvertFactorToValue(minLambdaProcessing2, maxLambdaProcessing2, x4);

                double sigmaComing1     = Rayleigh.ConvertLambdaToSigma(lambdaComing1);
                double sigmaComing2     = Rayleigh.ConvertLambdaToSigma(lambdaComing2);
                double sigmaProcessing1 = Rayleigh.ConvertLambdaToSigma(lambdaProcessing1);
                double sigmaProcessing2 = Rayleigh.ConvertLambdaToSigma(lambdaProcessing2);

                var comingDistribution1      = new Rayleigh(sigmaComing1);
                var comingDistribution2      = new Rayleigh(sigmaComing2);
                var proecssingDisctribution1 = new Rayleigh(sigmaProcessing1);
                var proecssingDisctribution2 = new Rayleigh(sigmaProcessing2);

                double y = 0;
                for (int exp = 0; exp < countIterationExperiments / 2; ++exp)
                {
                    ModelResult result = CalculateModel(comingDistribution1, comingDistribution2, proecssingDisctribution1, proecssingDisctribution2, count);
                    y += result.AverageTime;
                }
                y = Math.Round(y / (double)countIterationExperiments, 5);
                listY.Add(y);
            }

            double min1 = minLambdaComing1, min2 = minLambdaComing2, min3 = minLambdaProcessing1, min4 = minLambdaProcessing1;
            double max1 = maxLambdaComing1, max2 = maxLambdaComing2, max3 = maxLambdaProcessing1, max4 = maxLambdaProcessing1;

            b0_DFE    = CalculateB_DFE(0, 1, listX0, listY);
            b1_DFE    = CalculateB_DFE(min1, max1, listX1, listY);
            b2_DFE    = CalculateB_DFE(min2, max2, listX2, listY);
            b3_DFE    = CalculateB_DFE(min3, max3, listX3, listY);
            b4_DFE    = CalculateB_DFE(min4, max4, listX4, listY);
            b12_DFE   = CalculateB_DFE(min1 * min2, max1 * max2, listX12, listY);
            b13_DFE   = CalculateB_DFE(min1 * min3, max1 * max3, listX13, listY);
            b14_DFE   = CalculateB_DFE(min1 * min4, max1 * max4, listX14, listY);
            b23_DFE   = CalculateB_DFE(min2 * min3, max2 * max3, listX23, listY);
            b24_DFE   = CalculateB_DFE(min2 * min4, max2 * max4, listX24, listY);
            b34_DFE   = CalculateB_DFE(min3 * min4, max3 * max4, listX34, listY);
            b123_DFE  = CalculateB_DFE(min1 * min2 * min3, max1 * max2 * max3, listX123, listY);
            b124_DFE  = CalculateB_DFE(min1 * min2 * min4, max1 * max2 * max4, listX124, listY);
            b134_DFE  = CalculateB_DFE(min1 * min3 * min4, max1 * max3 * max4, listX134, listY);
            b234_DFE  = CalculateB_DFE(min2 * min3 * min4, max2 * max3 * max4, listX234, listY);
            b1234_DFE = CalculateB_DFE(min1 * min2 * min3 * min4, max1 * max2 * max3 * max4, listX1234, listY);

            for (int i = 0; i < n_DFE; ++i)
            {
                List <double> bl = new List <double> {
                    b0_DFE, b1_DFE, b2_DFE, b3_DFE, b4_DFE
                };
                List <double> xl = new List <double> {
                    listX0[i], listX1[i], listX2[i], listX3[i], listX4[i]
                };

                double yl = Math.Round(MultiplyCoefficients(bl, xl), 5);

                List <double> bcn = new List <double>
                {
                    b0_DFE,
                    b1_DFE,
                    b2_DFE,
                    b3_DFE,
                    b4_DFE,
                    b12_DFE,
                    b13_DFE,
                    b14_DFE,
                    b23_DFE,
                    b24_DFE,
                    b34_DFE,
                    b123_DFE,
                    b124_DFE,
                    b134_DFE,
                    b234_DFE,
                    b1234_DFE,
                };

                List <double> xcn = new List <double>
                {
                    listX0[i],
                    listX1[i],
                    listX2[i],
                    listX3[i],
                    listX4[i],
                    listX12[i],
                    listX13[i],
                    listX14[i],
                    listX23[i],
                    listX24[i],
                    listX34[i],
                    listX123[i],
                    listX124[i],
                    listX134[i],
                    listX234[i],
                    listX1234[i],
                };

                double ycn = Math.Round(MultiplyCoefficients(bcn, xcn), 5);

                yl  = Math.Abs(yl);
                ycn = Math.Abs(ycn);

                ListView_TableParametersDFE.Items.Add(new EquationCoefffcients(
                                                          i + 1,
                                                          listX0[i],
                                                          listX1[i],
                                                          listX2[i],
                                                          listX3[i],
                                                          listX4[i],
                                                          listX12[i],
                                                          listX13[i],
                                                          listX14[i],
                                                          listX23[i],
                                                          listX24[i],
                                                          listX34[i],
                                                          listX123[i],
                                                          listX124[i],
                                                          listX134[i],
                                                          listX234[i],
                                                          listX1234[i],
                                                          listY[i],
                                                          yl,
                                                          ycn,
                                                          Math.Round(Math.Abs(listY[i] - yl), 5),
                                                          Math.Round(Math.Abs(listY[i] - ycn), 5)
                                                          ));
            }

            ListView_TableResultsDFE.Items.Clear();
            ListView_TableResultsDFE.Items.Add(new EquationResult(
                                                   b0_DFE,
                                                   b1_DFE,
                                                   b2_DFE,
                                                   b3_DFE,
                                                   b4_DFE,
                                                   b13_DFE,
                                                   b12_DFE,
                                                   b14_DFE,
                                                   b23_DFE,
                                                   b24_DFE,
                                                   b34_DFE,
                                                   b123_DFE,
                                                   b124_DFE,
                                                   b134_DFE,
                                                   b234_DFE,
                                                   b1234_DFE
                                                   ));
        }
コード例 #45
0
 public void ValidateCumulativeDistribution([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double x)
 {
     var n = new Rayleigh(scale);
     Assert.AreEqual(1.0 - Math.Exp(-x * x / (2.0 * scale * scale)), n.CumulativeDistribution(x));
 }
コード例 #46
0
        private void AddPointDFE(double lambdaComing1, double lambdaComing2, double lambdaProcessing1, double lambdaProcessing2)
        {
            n_DFE++;
            double x0    = 1;
            double x1    = ConvertValueToFactor(minLambdaComing1, maxLambdaComing1, lambdaComing1);
            double x2    = ConvertValueToFactor(minLambdaComing2, maxLambdaComing2, lambdaComing2);
            double x3    = ConvertValueToFactor(minLambdaProcessing1, maxLambdaProcessing1, lambdaProcessing1);
            double x4    = ConvertValueToFactor(minLambdaProcessing2, maxLambdaProcessing2, lambdaProcessing2);
            double x12   = x1 * x2;
            double x13   = x1 * x3;
            double x14   = x1 * x4;
            double x23   = x2 * x3;
            double x24   = x2 * x4;
            double x34   = x3 * x4;
            double x123  = x1 * x2 * x3;
            double x124  = x1 * x2 * x4;
            double x134  = x1 * x3 * x4;
            double x234  = x2 * x3 * x4;
            double x1234 = x1 * x2 * x3 * x4;

            var comingDistribution1      = new Rayleigh(Rayleigh.ConvertLambdaToSigma(lambdaComing1));
            var comingDistribution2      = new Rayleigh(Rayleigh.ConvertLambdaToSigma(lambdaComing2));
            var proecssingDisctribution1 = new Rayleigh(Rayleigh.ConvertLambdaToSigma(lambdaProcessing1));
            var proecssingDisctribution2 = new Rayleigh(Rayleigh.ConvertLambdaToSigma(lambdaProcessing2));

            double y = 0;

            for (int exp = 0; exp < countIterationExperiments; ++exp)
            {
                ModelResult result = CalculateModel(comingDistribution1, comingDistribution2, proecssingDisctribution1, proecssingDisctribution2, count);
                y += result.AverageTime;
            }
            y = Math.Round(y / (double)countIterationExperiments, 5);

            List <double> bl = new List <double> {
                b0_DFE, b1_DFE, b2_DFE, b3_DFE, b4_DFE
            };
            List <double> xl = new List <double> {
                x0, x1, x2, x3, x4
            };

            double yl = Math.Round(MultiplyCoefficients(bl, xl), 5);

            List <double> bcn = new List <double>
            {
                b0_DFE,
                b1_DFE,
                b2_DFE,
                b3_DFE,
                b4_DFE,
                b12_DFE,
                b13_DFE,
                b14_DFE,
                b23_DFE,
                b24_DFE,
                b34_DFE,
                b123_DFE,
                b124_DFE,
                b134_DFE,
                b234_DFE,
                b1234_DFE,
            };

            List <double> xcn = new List <double>
            {
                x0,
                x1,
                x2,
                x3,
                x4,
                x12,
                x13,
                x14,
                x23,
                x24,
                x34,
                x123,
                x124,
                x134,
                x234,
                x1234,
            };

            double ycn = Math.Round(MultiplyCoefficients(bcn, xcn), 5);

            yl  = Math.Abs(yl);
            ycn = Math.Abs(ycn);

            ListView_TableParametersDFE.Items.Add(new EquationCoefffcients(
                                                      n_DFE,
                                                      x0,
                                                      x1,
                                                      x2,
                                                      x3,
                                                      x4,
                                                      x12,
                                                      x13,
                                                      x14,
                                                      x23,
                                                      x24,
                                                      x34,
                                                      x123,
                                                      x124,
                                                      x134,
                                                      x234,
                                                      x1234,
                                                      y,
                                                      yl,
                                                      ycn,
                                                      Math.Round(Math.Abs(y - yl), 5),
                                                      Math.Round(Math.Abs(y - ycn), 5)
                                                      ));
        }
コード例 #47
0
 public void ValidateDensityLn([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale, [Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double x)
 {
     var n = new Rayleigh(scale);
     Assert.AreEqual(Math.Log(x / (scale * scale)) - (x * (x / (2.0 * (scale * scale)))), n.DensityLn(x));
 }
コード例 #48
0
        public static double GetSampleFromScaleParameter(Random random, double scaleParameter)
        {
            var sample = Rayleigh.Sample(random, scaleParameter);

            return(sample);
        }
コード例 #49
0
 public void ValidateMaximum([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale)
 {
     var n = new Rayleigh(1.0);
     Assert.AreEqual(Double.PositiveInfinity, n.Maximum);
 }
コード例 #50
0
    private static void rayleigh_sample_test()

//****************************************************************************80
//
//  Purpose:
//
//    RAYLEIGH_SAMPLE_TEST tests RAYLEIGH_SAMPLE.
//
//  Licensing:
//
//    This code is distributed under the GNU LGPL license.
//
//  Modified:
//
//    27 February 2007
//
//  Author:
//
//    John Burkardt
//
    {
        const int SAMPLE_NUM = 1000;

        int j;
        int seed = 123456789;

        double[] x = new double [SAMPLE_NUM];

        Console.WriteLine("");
        Console.WriteLine("RAYLEIGH_SAMPLE_TEST");
        Console.WriteLine("  RAYLEIGH_MEAN computes the Rayleigh mean;");
        Console.WriteLine("  RAYLEIGH_SAMPLE samples the Rayleigh distribution;");
        Console.WriteLine("  RAYLEIGH_VARIANCE computes the Rayleigh variance.");

        double a = 2.0E+00;

        Console.WriteLine("");
        Console.WriteLine("  PDF parameter A =             " + a + "");

        if (!Rayleigh.rayleigh_check(a))
        {
            Console.WriteLine("");
            Console.WriteLine("RAYLEIGH_SAMPLE_TEST - Fatal error!");
            Console.WriteLine("  The parameters are not legal.");
            return;
        }

        double mean     = Rayleigh.rayleigh_mean(a);
        double variance = Rayleigh.rayleigh_variance(a);

        Console.WriteLine("  PDF mean =                    " + mean + "");
        Console.WriteLine("  PDF variance =                " + variance + "");

        for (j = 0; j < SAMPLE_NUM; j++)
        {
            x[j] = Rayleigh.rayleigh_sample(a, ref seed);
        }

        mean     = typeMethods.r8vec_mean(SAMPLE_NUM, x);
        variance = typeMethods.r8vec_variance(SAMPLE_NUM, x);
        double xmax = typeMethods.r8vec_max(SAMPLE_NUM, x);
        double xmin = typeMethods.r8vec_min(SAMPLE_NUM, x);

        Console.WriteLine("");
        Console.WriteLine("  Sample size =     " + SAMPLE_NUM + "");
        Console.WriteLine("  Sample mean =     " + mean + "");
        Console.WriteLine("  Sample variance = " + variance + "");
        Console.WriteLine("  Sample maximum =  " + xmax + "");
        Console.WriteLine("  Sample minimum =  " + xmin + "");
    }
コード例 #51
0
 public void ValidateMedian([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale)
 {
     var n = new Rayleigh(scale);
     Assert.AreEqual(scale * Math.Sqrt(Math.Log(4.0)), n.Median);
 }
コード例 #52
0
    private static void rayleigh_cdf_test()

//****************************************************************************80
//
//  Purpose:
//
//    RAYLEIGH_CDF_TEST tests RAYLEIGH_CDF.
//
//  Licensing:
//
//    This code is distributed under the GNU LGPL license.
//
//  Modified:
//
//    27 February 2007
//
//  Author:
//
//    John Burkardt
//
    {
        int i;
        int seed = 123456789;

        Console.WriteLine("");
        Console.WriteLine("RAYLEIGH_CDF_TEST");
        Console.WriteLine("  RAYLEIGH_CDF evaluates the Rayleigh CDF;");
        Console.WriteLine("  RAYLEIGH_CDF_INV inverts the Rayleigh CDF.");
        Console.WriteLine("  RAYLEIGH_PDF evaluates the Rayleigh PDF;");

        const double a = 2.0;

        Console.WriteLine("");
        Console.WriteLine("  PDF parameter A =             " + a + "");

        if (!Rayleigh.rayleigh_check(a))
        {
            Console.WriteLine("");
            Console.WriteLine("RAYLEIGH_CDF_TEST - Fatal error!");
            Console.WriteLine("  The parameters are not legal.");
            return;
        }

        Console.WriteLine("");
        Console.WriteLine("       X            PDF           CDF            CDF_INV");
        Console.WriteLine("");

        for (i = 1; i <= 10; i++)
        {
            double x   = Rayleigh.rayleigh_sample(a, ref seed);
            double pdf = Rayleigh.rayleigh_pdf(x, a);
            double cdf = Rayleigh.rayleigh_cdf(x, a);
            double x2  = Rayleigh.rayleigh_cdf_inv(cdf, a);

            Console.WriteLine("  "
                              + x.ToString(CultureInfo.InvariantCulture).PadLeft(12) + "  "
                              + pdf.ToString(CultureInfo.InvariantCulture).PadLeft(12) + "  "
                              + cdf.ToString(CultureInfo.InvariantCulture).PadLeft(12) + "  "
                              + x2.ToString(CultureInfo.InvariantCulture).PadLeft(12) + "");
        }
    }
コード例 #53
0
 public void ValidateSkewness([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale, [Values(0.63111065781893638)] double skn)
 {
     var n = new Rayleigh(scale);
     AssertHelpers.AlmostEqual(skn, n.Skewness, 17);
 }
コード例 #54
0
        public void ValidateMean(double scale)
        {
            var n = new Rayleigh(scale);

            Assert.AreEqual(scale * Math.Sqrt(Constants.PiOver2), n.Mean);
        }
コード例 #55
0
 public void ValidateToString()
 {
     var n = new Rayleigh(2.0);
     Assert.AreEqual("Rayleigh(Scale = 2)", n.ToString());
 }
コード例 #56
0
        public void ValidateVariance(double scale)
        {
            var n = new Rayleigh(scale);

            Assert.AreEqual((2.0 - Constants.PiOver2) * scale * scale, n.Variance);
        }
コード例 #57
0
 public void CanCreateRayleigh([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale)
 {
     var n = new Rayleigh(scale);
     Assert.AreEqual(scale, n.Scale);
 }
コード例 #58
0
        public void ValidateStdDev(double scale)
        {
            var n = new Rayleigh(scale);

            Assert.AreEqual(Math.Sqrt(2.0 - Constants.PiOver2) * scale, n.StdDev);
        }
コード例 #59
0
 public void CanSampleSequence()
 {
     var n = new Rayleigh(1.0);
     var ied = n.Samples();
     ied.Take(5).ToArray();
 }
コード例 #60
0
ファイル: RayleighTests.cs プロジェクト: wibble82/mmbot
        public void ValidateMode([Values(0.1, 1.0, 10.0, Double.PositiveInfinity)] double scale)
        {
            var n = new Rayleigh(scale);

            Assert.AreEqual(scale, n.Mode);
        }