private void GenerateNormalDistrib() { if (!isValid()) { MessageBox.Show("Ingrese cantidad de números a generar."); return; } if (nudNormalDistribMedia.Value == 0) { MessageBox.Show("Media tiene que ser mayor a 0."); return; } var rndNumCount = Convert.ToUInt32(nudRandomNumbersCount.Value); var seed = Convert.ToInt32(nudNormalDistribSeed.Value); var media = Convert.ToDouble(nudNormalDistribMedia.Value); var deviation = Convert.ToDouble(nudNormalDistribDeviation.Value); var numIntervals = Convert.ToUInt32(cmbIntervalo.Text); var rndGen = new RandomGenra2(); this.Cursor = Cursors.WaitCursor; //calculo numero aletorios randomNumbers = rndGen.GenerateNormalDistribution(media, deviation, rndGen.GenerateCSharpRandomsList(seed, rndNumCount)); FillDgNumbers(randomNumbers); this.Cursor = Cursors.Default; //calculo frecuencias if (numIntervals <= 0) { return; } timer = Stopwatch.StartNew(); frecuencies = rndGen.GenerateNormalFrecuencies(numIntervals, media, deviation, randomNumbers); timer.Stop(); lblElapsedTimeFrecuencies.Text = timer.ElapsedMilliseconds.ToString(); FillDbFrecuencies(frecuencies); gradlib.Visible = true; gradlib.Text = String.Format("Grados de Libertad: {0}", (frecuencies.Count - 1)); fillChart(frecuencies); }
private void GenerateUniformDistrib() { if (!isValid()) { MessageBox.Show("Ingrese cantidad de números a generar."); return; } // Variables tomadas de interfaz var rndNumCount = Convert.ToUInt32(nudRandomNumbersCount.Value); var seed = Convert.ToInt32(nudUniformDistribSeed.Value); var A = Convert.ToDouble(nudUniformDistribA.Value); var B = Convert.ToDouble(nudUniformDistribB.Value); var numIntervals = Convert.ToUInt32(cmbIntervalo.Text); var rndGen = new RandomGenra2(); this.Cursor = Cursors.WaitCursor; //calculo numero aletorios randomNumbers = rndGen.GenerateUniformDistribution(A, B, rndGen.GenerateCSharpRandoms(seed, rndNumCount)); FillDgNumbers(randomNumbers); this.Cursor = Cursors.Default; //calculo frecuencias if (numIntervals <= 0) { return; } timer = Stopwatch.StartNew(); frecuencies = rndGen.GenerateUniformFrecuencies(numIntervals, randomNumbers, A, B); FillDbFrecuencies(frecuencies); gradlib.Visible = true; gradlib.Text = String.Format("Grados de Libertad: {0}", (frecuencies.Count - 1)); fillChart(frecuencies); }