Beispiel #1
0
        private void button1_Click(object sender, EventArgs e)
        {
            string texto = textBox1.Text;

            if (texto == "" || textBox1.Text == "")
            {
                texto = "invalido";
            }


            double textoAInt = 0;

            bool result = double.TryParse(texto, out textoAInt);

            if (result)
            {
                Regresion   nuevaRegresion = new Regresion();
                PasarNumero owner          = this.Owner as PasarNumero;

                nuevaRegresion.CalcularLagrange(owner.PasarDatos(), owner.PasarPuntos(), textoAInt);
            }
            else
            {
                MessageBox.Show("Ingrese los datos correctamente");
            }
        }
Beispiel #2
0
        private void button1_Click(object sender, EventArgs e)
        {
            double[,] Matriz = new double[Cantidad, 2];

            for (int i = 0; i < Cantidad; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    string texto = dataGridView1.Rows[i].Cells[j].Value.ToString();

                    if (texto == "")
                    {
                        texto = "Invalido";
                    }
                    double textoADouble;

                    bool result = double.TryParse(texto, out textoADouble);

                    if (result)
                    {
                        Matriz[i, j] = textoADouble;
                    }
                }
            }
            MatrizUsada = Matriz;
            Regresion nuevaRegresion = new Regresion();

            if (Metodo == "Regresión Lineal por mínimos cuadrados")
            {
                ResultadoRegresion nuevoResultado = new ResultadoRegresion();
                nuevoResultado = nuevaRegresion.CalcularRegresionLineal(Matriz, Cantidad);

                MessageBox.Show("El termino independiente es: " + nuevoResultado.Resultadoa0 + ", su coeficiente es: " + nuevoResultado.Resultadoa1 + ", y su coeficiente de correlacion es: " + nuevaRegresion.CoefienteCorrelacion(Matriz, Cantidad, nuevoResultado.Resultados));
            }
            else
            {
                if (Metodo == "Regresión Polinomial por mínimos cuadrados")
                {
                    var nuevoResultado = nuevaRegresion.CalcularRegrecionPolinomial(Matriz, Cantidad, 2);
                    ResultadosRegresion    = nuevoResultado.Resultados;
                    CoeficienteCorrelacion = nuevaRegresion.CoefienteCorrelacion(Matriz, Cantidad, nuevoResultado.Resultados);
                    ResultadosRegresion nuevoResultadoRegresion = new Regresión.ResultadosRegresion();
                    nuevoResultadoRegresion.Owner = this;
                    nuevoResultadoRegresion.Show();
                }
                else
                {
                    var nuevoResultado = nuevaRegresion.CalcularLagrange(Matriz, Cantidad, numeroLagrange);
                    MessageBox.Show("El valor correspondiente cuando x= " + numeroLagrange + " es: " + nuevoResultado + ", a traves del metodo de Lagrange");
                }
            }
        }