Example #1
0
        private void GenerateExponentialDistrib()
        {
            if (!isValid())
            {
                MessageBox.Show("Ingrese cantidad de nĂºmeros a generar.");
                return;
            }

            if (nudExponentialDistribLambda.Value == 0)
            {
                MessageBox.Show("Lambda tiene que ser mayor a 0.");
                return;
            }

            var rndNumCount  = Convert.ToUInt32(nudRandomNumbersCount.Value);
            var seed         = Convert.ToInt32(nudExponentialDistribSeed.Value);
            var lambda       = Convert.ToDouble(nudExponentialDistribLambda.Value);
            var numIntervals = Convert.ToUInt32(cmbIntervalo.Text);

            var rndGen = new RandomGenra2();

            this.Cursor = Cursors.WaitCursor;

            //calculo numero aletorios
            randomNumbers = rndGen.GenerateExponentialDistribution(lambda, rndGen.GenerateCSharpRandoms(seed, rndNumCount));
            FillDgNumbers(randomNumbers);
            this.Cursor = Cursors.Default;

            //calculo frecuencias
            if (numIntervals <= 0)
            {
                return;
            }

            timer       = Stopwatch.StartNew();
            frecuencies = rndGen.GenerateExponentialFrecuencies(numIntervals, lambda, 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);
        }
Example #2
0
        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);
        }