public ExponentialGenerator(int a, int m, double r, double lambda) { if (a > 0) { LehmerGenerator lehmerGenerator = new LehmerGenerator(a, m, r); lehmerNumbers = lehmerGenerator.Generate(out period, out aperiodicity); this.lambda = lambda; } else { throw new ArgumentException(); } }
public GaussGenerator(int a, int m, double r, double mx, double sx) { if (a > 0) { LehmerGenerator lehmerGenerator = new LehmerGenerator(a, m, r); lehmerNumbers = lehmerGenerator.Generate(out period, out aperiodicity); this.m = mx; this.s = sx; } else { throw new ArgumentException(); } }
public TriangleGenerator(int a, int m, double r, double from, double to) { if (a > 0) { LehmerGenerator lehmerGenerator = new LehmerGenerator(a, m, r); lehmerNumbers = lehmerGenerator.Generate(out period, out aperiodicity); this.from = from; this.to = to; } else { throw new ArgumentException(); } }
public SimpsonGenerator(int a, int m, double r, double from, double to) { if (a > 0) { LehmerGenerator lehmerGenerator = new LehmerGenerator(a, m, r); lehmerNumbers = lehmerGenerator.Generate(out period, out aperiodicity); modifiedlehmerNumbers = new List<double>(); foreach (double number in lehmerNumbers) { modifiedlehmerNumbers.Add(from / 2 + (to / 2 - from / 2) * number); } } else { throw new ArgumentException(); } }
private void btnGenerate_Click(object sender, EventArgs e) { try { int a = Int32.Parse(textBox1.Text); int m = Int32.Parse(textBox2.Text); double r = Double.Parse(textBox3.Text); IRandomNumberGenerator numberGenerator = null; switch (lstGenerators.SelectedIndex) { case 0: numberGenerator = new LehmerGenerator(a, m, r); break; case 1: numberGenerator = new UniformGenerator(a, m, r, Double.Parse(ArgA.Text), Double.Parse(ArgB.Text)); break; case 2: numberGenerator = new GaussGenerator(a, m, r, Double.Parse(ArgA.Text), Double.Parse(ArgB.Text)); break; case 3: numberGenerator = new ExponentialGenerator(a, m, r, Double.Parse(ArgA.Text)); break; case 4: numberGenerator = new GammaGenerator(a, m, r, Double.Parse(ArgA.Text), Double.Parse(ArgB.Text)); break; case 5: numberGenerator = new TriangleGenerator(a, m, r, Double.Parse(ArgA.Text), Double.Parse(ArgB.Text)); break; case 6: numberGenerator = new SimpsonGenerator(a, m, r, Double.Parse(ArgA.Text), Double.Parse(ArgB.Text)); break; } int period; int aperiodicity; List<double> numbers = new List<double>(numberGenerator.Generate(out period, out aperiodicity)); ExpectedValue.Text = numbers.ExpectedValue().ToString(); Dispersion.Text = numbers.Dispersion().ToString(); StandartDeviation.Text = numbers.StandartDeviation().ToString(); Period.Text = period.ToString(); Aperiodicity.Text = aperiodicity.ToString(); Uniformity.Text = numbers.Uniformity().ToString(); int intervalCount = Int32.Parse(textBox7.Text); if (intervalCount >= 5 && intervalCount <= 25) { UpdateChart(numbers, intervalCount); } else { throw new Exception(); } SaveNumbersToFile(numbers); } catch { MessageBox.Show("Введите корректные исходные данные", "Ошибка"); } }