Example #1
0
 void btnOk_Click(object sender, EventArgs e)
 {
     try
     {
         Sample[] arrSX = new Sample[matrX.GetLength(1)];
         for (int j = 0; j < matrX.GetLength(1); j++)
         {
             double[] arrX = new double[matrX.GetLength(0)];
             for (int i = 0; i < matrX.GetLength(0); i++)
             {
                 arrX[i] = matrX[i, j];
             }
             arrSX[j] = new TranSample(new Sample(arrXName[j],
                                                  string.Format("x<sub>{0}</sub>", j + 1), arrX),
                                       dgv.Rows[j].Cells[1].Value.ToString());
         }
         Regression[] arrReg = new Regression[matrY.GetLength(1)];
         rep = "ПАРАМЕТРИЧЕСКАЯ ИДЕНТИФИКАЦИЯ<br>";
         for (int j = 0; j < matrY.GetLength(1); j++)
         {
             double[] arrY = new double[matrY.GetLength(0)];
             for (int i = 0; i < matrY.GetLength(0); i++)
             {
                 arrY[i] = matrY[i, j];
             }
             arrReg[j] = new Regression(new Sample("y", string.Format("y<sub>{0}</sub>", j + 1), arrY), arrSX);
             rep      += arrReg[j].GetRegReport() + "<br>";
         }
         Quality.GenErr(matrX, matrY, arrReg, int.Parse(tbN.Text), double.Parse(tbA.Text),
                        double.Parse(tbB.Text), out arrI, out matrXM, out matrYM);
         rep += string.Format("ПАРАМЕТРЫ ГЕНЕРАЦИИ<br>n = {0}<br>A = {1}<br>B = {2}<br><br>",
                              tbN.Text, tbA.Text, tbB.Text);
         rep += "ПЕРЕЧЕНЬ ИЗМЕНЕННЫХ НАБЛЮДЕНИЙ<br>";
         foreach (int i in arrI)
         {
             rep += string.Format("{0} ", i + 1);
         }
         WBForm wbf = new WBForm("Параметрическая идентификация и генерация наблюдений", rep);
         DialogResult = DialogResult.OK;
         Close();
         wbf.ShowDialog();
     }
     catch
     {
         MessageBox.Show("Ошибка генерации");
     }
 }
Example #2
0
 void btnOk_Click(object sender, EventArgs e)
 {
     try
     {
         Regression[] arrReg = new Regression[matrY.GetLength(1)];
         repSmp = repHSmp = repId = repHId = repCorr = repHCorr = repGen = "";
         Sample[] arrSX = new Sample[matrX.GetLength(1)];
         for (int j = 0; j < arrSX.Length; j++)
         {
             double[] arrX = new double[matrX.GetLength(0)];
             for (int i = 0; i < matrX.GetLength(0); i++)
             {
                 arrX[i] = matrX[i, j];
             }
             arrSX[j] = new Sample(arrXName[j], string.Format("x<sub>{0}</sub>", j + 1), arrX);
             arrSX[j].Calculate();
             repSmp  += arrSX[j].GetReport();
             repHSmp += arrSX[j].GetHypReport();
         }
         repId = "ПАРАМЕТРИЧЕСКАЯ ИДЕНТИФИКАЦИЯ<br>";
         Sample[] arrSY = new Sample[matrY.GetLength(1)];
         for (int j = 0; j < matrY.GetLength(1); j++)
         {
             Sample[] arrTSX = new Sample[matrX.GetLength(1)];
             for (int k = 0; k < matrX.GetLength(1); k++)
             {
                 arrTSX[k] = new TranSample(arrSX[k],
                                            dgv.Rows[k].Cells[j + 1].Value.ToString());
             }
             double[] arrY = new double[matrY.GetLength(0)];
             for (int i = 0; i < matrY.GetLength(0); i++)
             {
                 arrY[i] = matrY[i, j];
             }
             Sample smpY = new Sample(arrYName[j], string.Format("y<sub>{0}</sub>", j + 1), arrY);
             smpY.Calculate();
             arrSY[j]  = smpY;
             repSmp   += smpY.GetReport();
             repHSmp  += smpY.GetHypReport();
             arrReg[j] = new Regression(smpY, arrTSX);
             repId    += arrReg[j].GetRegReport() + "<br>";
             repCorr  += arrReg[j].GetCorrReport();
             if (cbH.Checked)
             {
                 arrReg[j].CheckHypothesises(double.Parse(tbAlpha.Text));
                 repHId   += arrReg[j].GetHypRegrReport();
                 repHCorr += arrReg[j].GetHypCorrReport();
             }
         }
         Sample[] arrSYX = new Sample[matrX.GetLength(1) + matrY.GetLength(1) - 1];
         for (int i = 0; i < arrSY.Length - 1; i++)
         {
             arrSYX[i] = arrSY[i + 1];
         }
         for (int i = 0; i < arrSX.Length; i++)
         {
             arrSYX[arrSY.Length - 1 + i] = arrSX[i];
         }
         Regression reg = new Regression(arrSY[0], arrSYX);
         repCorrXY = reg.GetCorrReport().Replace("<P>ПОКАЗАТЕЛЬ: y<sub>1</sub><BR>", "");
         if (cbG.Checked)
         {
             Quality.GenErr(matrX, matrY, arrReg, int.Parse(tbN.Text), double.Parse(tbA.Text),
                            double.Parse(tbB.Text), out arrI, out matrXM, out matrYM);
             repGen += string.Format("ПАРАМЕТРЫ ГЕНЕРАЦИИ<br>n = {0}<br>A = {1}<br>B = {2}<br><br>",
                                     tbN.Text, tbA.Text, tbB.Text);
             repGen += "ПЕРЕЧЕНЬ ИЗМЕНЕННЫХ НАБЛЮДЕНИЙ<br>";
             foreach (int i in arrI)
             {
                 repGen += string.Format("{0} ", i + 1);
             }
         }
         else
         {
             matrXM = matrX;
             matrYM = matrY;
         }
         DialogResult = DialogResult.OK;
         Close();
     }
     catch
     {
         MessageBox.Show("Ошибка генерации");
     }
 }