Esempio n. 1
0
        // Метод Лемера
        private void button4_Click(object sender, EventArgs e)
        {
            int size           = Convert.ToInt32(textBox7.Text);
            int countIntervals = Convert.ToInt32(textBox8.Text);
            int countSeries    = Convert.ToInt32(textBox9.Text);

            Series[] seriesMass = new Series[countSeries];

            for (int s = 0; s < countSeries; s++)
            {
                seriesMass[s] = new Series {
                    Name = "Испытание " + (countLehmerSeries + 1)
                };
                countLehmerSeries++;

                double[] values = Algs.Lehmer(size);
                int[]    arr    = new int[countIntervals];

                foreach (var value in values)
                {
                    arr[(int)(value * countIntervals)]++;
                }

                // Добавление данных в серию
                for (int i = 0; i < countIntervals; i++)
                {
                    seriesMass[s].Points.AddXY(i + 1, arr[i]);
                }

                // Добавление серии в гистограмму
                chartLehmer.Series.Add(seriesMass[s]);
            }
        }
Esempio n. 2
0
            public static double[] GExp(int n, int s, int AlgIndex)
            {
                double[] mass = new double[s];

                double[] x = new double[s];

                switch (AlgIndex)
                {
                case (-1):
                case (0):
                    x = Algs.CSRandom(s);
                    break;

                case (1):
                    x = Algs.SCongruence(n, s);
                    break;

                case (2):
                    x = Algs.Lehmer(s);
                    break;
                }

                for (int i = 0; i < s; i++)
                {
                    mass[i] = Math.Pow(-Math.Log(x[i]) / 1, 1.3);
                }

                return(mass);
            }
Esempio n. 3
0
            public static double[] Muller(int n, int s, int AlgIndex)
            {
                double[] mass = new double[s];

                double[] x = new double[s * 2];

                switch (AlgIndex)
                {
                case (-1):
                case (0):
                    x = Algs.CSRandom(s * 2);
                    break;

                case (1):
                    x = Algs.SCongruence(n, s * 2);
                    break;

                case (2):
                    x = Algs.Lehmer(s * 2);
                    break;
                }

                for (int i = 0; i < s - 1; i++)
                {
                    for (int j = i * 2; j < (i + 1) * 2; j++)
                    {
                        mass[i] = (-6 + Math.Sqrt(-2 * Math.Log(x[j]))) * (-6 + Math.Sin(2 * Math.PI * x[j + 1]));
                    }
                }

                return(mass);
            }
Esempio n. 4
0
            public static double[] Triangle(int n, int s, int AlgIndex)
            {
                double[] mass = new double[s];

                int b = n / 2;

                double[] x = new double[s * 2];

                switch (AlgIndex)
                {
                case (-1):
                case (0):
                    x = Algs.CSRandom(s * 2);
                    break;

                case (1):
                    x = Algs.SCongruence(n, s * 2);
                    break;

                case (2):
                    x = Algs.Lehmer(s * 2);
                    break;
                }

                for (int i = 0; i < s; i++)
                {
                    x[i]     = x[i] * b;
                    x[s + i] = b - x[s + i] * b;

                    mass[i] = x[i] + x[s + i];
                }

                return(mass);
            }
Esempio n. 5
0
            public static double[] Trapezoid(int n, int s, int v, int AlgIndex)
            {
                double[] mass = new double[s];

                int b = (n / 2) - (v / 2);
                int c = (n / 2) + (v / 2);

                double[] x = new double[s * 2];

                switch (AlgIndex)
                {
                case (-1):
                case (0):
                    x = Algs.CSRandom(s * 2);
                    break;

                case (1):
                    x = Algs.SCongruence(n, s * 2);
                    break;

                case (2):
                    x = Algs.Lehmer(s * 2);
                    break;
                }

                for (int i = 0; i < s; i++)
                {
                    x[i]    *= b;
                    x[s + i] = x[s + i] * -c + c;

                    mass[i] = x[i] + x[s + i];
                }

                return(mass);
            }
Esempio n. 6
0
            public static double[] Normal(int n, int s, int Mx, int sigma, int AlgIndex)
            {
                double[] mass = new double[s];
                double   m    = n;

                double[] x = new double[s * n];

                switch (AlgIndex)
                {
                case (-1):
                case (0):
                    x = Algs.CSRandom(s * n);
                    break;

                case (1):
                    x = Algs.SCongruence(n, s * n);
                    break;

                case (2):
                    x = Algs.Lehmer(s * n);
                    break;
                }

                for (int i = 0; i < s; i++)
                {
                    double S = 0;

                    for (int j = n * i; j < n * (i + 1); j++)
                    {
                        S += x[j];
                    }

                    mass[i] = Mx + (sigma * (Math.Sqrt(12 / m) * (S - (m / 2))));
                }

                return(mass);
            }