Exemple #1
0
        // Экспоненциальное распределение
        private void ExponentialRaspred()
        {
            LemerRandomSequence rand = new LemerRandomSequence(ulong.Parse(textBox_a.Text), ulong.Parse(textBox_m.Text), ulong.Parse(textBox_R0.Text));
            int    N = int.Parse(textBox2.Text);       // Количество генерируемых чисел
            double λ = double.Parse(textBox1.Text);    // Параметр экспоненциального распределения

            RandomSequence = new double[N];
            for (int i = 0; i < N; i++)
            {
                RandomSequence[i] = -Math.Log(rand.Next()) / λ;
            }

            CalculateStatValues();
            DrawHistogram();
            distNameLabel.Text = "Экспоненциальное распределение\r\nλ = " + λ.ToString() + ", N = " + N.ToString();
        }
Exemple #2
0
        private void SimpsonRaspred()
        {
            LemerRandomSequence rand = new LemerRandomSequence(ulong.Parse(textBox_a.Text), ulong.Parse(textBox_m.Text), ulong.Parse(textBox_R0.Text));
            int    N = int.Parse(textBox3.Text);
            double a = double.Parse(textBox1.Text);
            double b = double.Parse(textBox2.Text);

            RandomSequence = new double[N];

            for (int i = 0; i < N; i++)
            {
                RandomSequence[i] = a / 2 + (b / 2 - a / 2) * rand.Next() + a / 2 + (b / 2 - a / 2) * rand.Next();
            }

            CalculateStatValues();
            DrawHistogram();
            distNameLabel.Text = "Распределение Симпсона\r\na = " + a.ToString() + ", b = " + b.ToString() + ", N = " + N.ToString();
        }
Exemple #3
0
        private void calculateButton_Click(object sender, EventArgs e)
        {
            LemerRandom = new LemerRandomSequence(double.Parse(textBox_a.Text), double.Parse(textBox_m.Text), double.Parse(textBox_R0.Text));

            findPeriod();
            drawHistogram();

            getStatValues();
            checkUniformityIndirect();

            /*
             * //find a, m, R0 fo period >= 50000
             * double a = 1000, r0 = 3571, m = 100000;
             * LemerRandom = new LemerRandomSequence(a, m, r0);
             * while (findPeriod() < 50000)
             * {
             *
             *  m++;
             *  if (m > 1000000)
             *  {
             *      m = 1000;
             *      a++;
             *      if (a > 10000)
             *      {
             *
             *          a = 1;
             *          r0++;
             *          if (r0 > 10000)
             *          {
             *              break;
             *          }
             *      }
             *  }
             *  LemerRandom = new LemerRandomSequence(a, m, r0);
             * }
             * textBox_a.Text = a.ToString();
             * textBox_m.Text = m.ToString();
             * textBox_R0.Text = r0.ToString();
             */

            saveSequence("LemerRandomSequence.txt");
            RandomSequence.Clear();
            LemerRandom.Reset();
        }
Exemple #4
0
        // Равномерное распределение
        private void UniformDistrib()
        {
            LemerRandomSequence rand = new LemerRandomSequence(ulong.Parse(textBox_a.Text), ulong.Parse(textBox_m.Text), ulong.Parse(textBox_R0.Text));

            int    N = int.Parse(textBox3.Text);// Количество генерируемых чисел
            double a = double.Parse(textBox1.Text);
            double b = double.Parse(textBox2.Text);

            RandomSequence = new double[N];

            for (int i = 0; i < N; i++)
            {
                RandomSequence[i] = a + (b - a) * rand.Next();
            }

            CalculateStatValues();
            DrawHistogram();
            distNameLabel.Text = "Равномерное распределение\r\na = " + a.ToString() + ", b = " + b.ToString() + ", N = " + N.ToString();
        }
Exemple #5
0
        // Треугольное распределение
        private void TriangleRaspred()
        {
            LemerRandomSequence rand = new LemerRandomSequence(ulong.Parse(textBox_a.Text), ulong.Parse(textBox_m.Text), ulong.Parse(textBox_R0.Text));
            int    N = int.Parse(textBox3.Text);
            double a = double.Parse(textBox1.Text);
            double b = double.Parse(textBox2.Text);

            RandomSequence = new double[N];

            for (int i = 0; i < N; i++)
            {
                double R1 = rand.Next();
                double R2 = rand.Next();
                RandomSequence[i] = a + (b - a) * Math.Max(R1, R2);
            }


            CalculateStatValues();
            DrawHistogram();
            distNameLabel.Text = "Треугольное распределение\r\na = " + a.ToString() + ", b = " + b.ToString() + ", N = " + N.ToString();
        }
Exemple #6
0
        // Гамма-распределение
        private void GammaRaspred()
        {
            LemerRandomSequence rand = new LemerRandomSequence(ulong.Parse(textBox_a.Text), ulong.Parse(textBox_m.Text), ulong.Parse(textBox_R0.Text));
            int    N = int.Parse(textBox3.Text);       // Количество генерируемых чисел
            int    η = int.Parse(textBox1.Text);
            double λ = double.Parse(textBox2.Text);

            RandomSequence = new double[N];
            for (int i = 0; i < N; i++)
            {
                double tmp = 1;
                for (int j = 0; j < η; j++)
                {
                    tmp *= rand.Next();
                }

                RandomSequence[i] = -Math.Log(tmp) / λ;
            }

            CalculateStatValues();
            DrawHistogram();
            distNameLabel.Text = "Гамма-распределение\r\nη = " + η.ToString() + ", λ = " + λ.ToString() + ", N = " + N.ToString();
        }
Exemple #7
0
        // Гауссовское распределение
        private void GaussRaspred()
        {
            LemerRandomSequence rand = new LemerRandomSequence(ulong.Parse(textBox_a.Text), ulong.Parse(textBox_m.Text), ulong.Parse(textBox_R0.Text));
            int    N   = int.Parse(textBox4.Text);     // Количество генерируемых чисел
            double m   = double.Parse(textBox1.Text);  // Мат. ожидание
            double sko = double.Parse(textBox2.Text);  // СКО
            int    n   = int.Parse(textBox3.Text);     // Число суммируемых равномерно распределённых чисел

            RandomSequence = new double[N];
            for (int i = 0; i < N; i++)
            {
                double tmp = 0;
                for (int j = 0; j < n; j++)
                {
                    tmp += rand.Next();
                }

                RandomSequence[i] = m + sko * Math.Sqrt(12.0 / n) * (tmp - (double)n / 2);
            }

            CalculateStatValues();
            DrawHistogram();
            distNameLabel.Text = "Гауссовское распределение\r\nm = " + m.ToString() + ", σ = " + sko.ToString() + ", N = " + N.ToString();
        }