Exemple #1
0
        void removeFactorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (arrSmp.Length < 2)
                {
                    return;
                }
                int      index     = lvSample.SelectedIndices[0];
                Sample[] arrSmpNew = new Sample[arrSmp.Length - 1];
                for (int i = 0; i < index; i++)
                {
                    arrSmpNew[i] = arrSmp[i];
                }
                for (int i = index; i < arrSmpNew.Length; i++)
                {
                    arrSmpNew[i] = arrSmp[i + 1];
                }
                arrSmp = arrSmpNew;

                Sample[] arrTranSmpNew = new TranSample[arrTranSmp.Length - 1];
                for (int i = 0; i < index; i++)
                {
                    arrTranSmpNew[i] = arrTranSmp[i];
                }
                for (int i = index; i < arrTranSmpNew.Length; i++)
                {
                    arrTranSmpNew[i] = arrTranSmp[i + 1];
                }
                arrTranSmp = arrTranSmpNew;

                lvSample.Items.RemoveAt(index);
            }
            catch { }
        }
Exemple #2
0
 void doIdentToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         string[] arrName = new string[arrTranSmp.Length];
         for (int i = 0; i < arrName.Length; i++)
         {
             arrName[i] = arrTranSmp[i].GetName();
         }
         SelFactorForm sFormY = new SelFactorForm(arrName, null);
         if (sFormY.ShowDialog() != DialogResult.OK)
         {
             return;
         }
         SelFactorForm sFormX = new SelFactorForm(arrName,
                                                  "Выберете влияющий признак");
         if (sFormX.ShowDialog() != DialogResult.OK)
         {
             return;
         }
         int       indexX = sFormX.GetIndex(), indexY = sFormY.GetIndex();
         IdentForm iForm = new IdentForm(arrSmp[indexX],
                                         arrSmp[indexY]);
         if (iForm.ShowDialog() != DialogResult.OK)
         {
             return;
         }
         arrTranSmp[indexX] = new TranSample(arrSmp[indexX], iForm.GetTransform());
         lvSample.Items[indexX].SubItems[1].Text = iForm.GetTransform();
         arrTranSmp[indexX].DoHistogram(useSturgess);
     }
     catch { }
 }
Exemple #3
0
        void addFactorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                int        n     = arrSmp[0].GetLength();
                string     mark  = string.Format("x<SUB>{0}</SUB>", arrSmp.Length + 1);
                Sample     smp   = new Sample("Новый признак", mark, new double[n]);
                FactorForm fForm = new FactorForm(smp, "Нет");
                if (fForm.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                Sample[] arrSmpNew = new Sample[arrSmp.Length + 1];
                arrSmp.CopyTo(arrSmpNew, 0);
                arrSmpNew[arrSmp.Length] = fForm.GetSample();
                arrSmpNew[arrSmp.Length].DoHistogram(useSturgess);
                arrSmp = arrSmpNew;

                TranSample[] arrTranSmpNew = new TranSample[arrSmp.Length];
                arrTranSmp.CopyTo(arrTranSmpNew, 0);
                TranSample ts = fForm.GetTranSample();
                ts.DoHistogram(useSturgess);
                arrTranSmpNew[arrTranSmp.Length] = ts;
                arrTranSmp = arrTranSmpNew;

                lvSample.Items.Add(new ListViewItem(new string[] { ts.GetName(), ts.GetTransform() }));
            }
            catch { }
        }
Exemple #4
0
 void btnOk_Click(object sender, EventArgs e)
 {
     try
     {
         smp.SetName(tbName.Text);
         ts           = new TranSample(smp, cbTran.Text);
         DialogResult = DialogResult.OK;
         Close();
     }
     catch { }
 }
Exemple #5
0
        public MainForm()
        {
            InitializeComponent();
            //arrSmp = new Sample[1];
            //arrTranSmp = new TranSample[1];
            //arrSmp[0] = new Sample("x", "x<SUB>1</SUB>", new double[] { 1, 2, 3, 4 });
            //arrTranSmp[0] = new TranSample(arrSmp[0], "Нет");
            //lvSample.Items.Add(new ListViewItem(new string[] { "x", "Нет" }));

            arrSmp        = new Sample[2];
            arrTranSmp    = new TranSample[2];
            arrSmp[0]     = new Sample("x", "x<SUB>1</SUB>", new double[] { 1, 2, 3, 4 });
            arrSmp[1]     = new Sample("y", "x<SUB>2</SUB>", new double[] { 3, 5, 7, 9 });
            arrTranSmp[0] = new TranSample(arrSmp[0], "Нет");
            arrTranSmp[1] = new TranSample(arrSmp[1], "Нет");
            lvSample.Items.Add(new ListViewItem(new string[] { "x", "Нет" }));
            lvSample.Items.Add(new ListViewItem(new string[] { "y", "Нет" }));

            alphaToolStripTextBox.Text = alpha.ToString();
        }
Exemple #6
0
        void editFactorToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                int        index     = lvSample.SelectedIndices[0];
                string     transform = lvSample.Items[index].SubItems[1].Text;
                FactorForm fForm     = new FactorForm(arrSmp[index], transform);
                if (fForm.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                arrSmp[index] = fForm.GetSample();
                TranSample ts = fForm.GetTranSample();
                ts.DoHistogram(useSturgess);
                arrTranSmp[index] = ts;

                lvSample.Items[index].SubItems[0].Text = arrSmp[index].GetName();
                lvSample.Items[index].SubItems[1].Text = ts.GetTransform();
            }
            catch { }
        }
Exemple #7
0
 void lbTran_SelectedIndexChanged(object sender, EventArgs e)
 {
     try
     {
         int        index = lbTran.SelectedIndex;
         TranSample ts    = arrTranSmp[index];
         Regression reg   = arrReg[index];
         ps.Clear();
         LinePlot lp = new LinePlot();
         lp.AbscissaData = ts.CloneArray();
         lp.OrdinateData = reg.CloneArray();
         ps.Add(lp);
         PointPlot pp = new PointPlot();
         pp.AbscissaData = ts.CloneArray();
         pp.OrdinateData = smpY.CloneArray();
         ps.Add(pp);
         ps.XAxis1.Label = string.Format("{0} [{1}]", smpX.GetName(), arrTranName[index]);
         ps.YAxis1.Label = smpY.GetName();
         ps.Refresh();
     }
     catch { }
 }
Exemple #8
0
        void editDataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                string[] arrTran = new string[arrTranSmp.Length];
                for (int i = 0; i < arrTran.Length; i++)
                {
                    arrTran[i] = ((TranSample)arrTranSmp[i]).GetTransform();
                }
                DataForm daForm = new DataForm(arrSmp);
                if (daForm.ShowDialog() != DialogResult.OK)
                {
                    return;
                }
                this.arrSmp = daForm.GetSamples();
                foreach (Sample s in arrSmp)
                {
                    s.DoHistogram(true);
                }
                arrTranSmp = new TranSample[arrSmp.Length];
                for (int i = 0; i < arrTranSmp.Length; i++)
                {
                    arrTranSmp[i] = new TranSample(this.arrSmp[i], "Нет");
                    arrTranSmp[i].DoHistogram(useSturgess);
                }

                lvSample.Items.Clear();
                lvSample.SuspendLayout();
                for (int i = 0; i < arrSmp.Length; i++)
                {
                    lvSample.Items.Add(new ListViewItem(new string[] {
                        arrSmp[i].GetName(), arrTran[i]
                    }));
                }
                lvSample.ResumeLayout();
            }
            catch { }
        }
Exemple #9
0
 public IdentForm(Sample smpX, Sample smpY)
 {
     InitializeComponent();
     this.smpY   = smpY;
     this.smpX   = smpX;
     arrTranName = new string[] { "Нет", "Квадрат", "Куб", "Обратное",
                                  "Обратное в квадрате", "Квадратный корень", "Единица на квадратный корень",
                                  "Натуральный логарифм", "Экспонента" };
     arrTranSmp = new TranSample[arrTranName.Length];
     arrReg     = new Regression[arrTranName.Length];
     for (int i = 0; i < arrTranName.Length; i++)
     {
         TranSample ts = new TranSample(smpX, arrTranName[i]);
         arrTranSmp[i] = ts;
         arrReg[i]     = new Regression(smpY, new Sample[] { ts });
         string transform = arrTranSmp[i].GetTransform();
         if (transform == "Нет")
         {
             transform = "Линейное";
         }
         lbTran.Items.Add(string.Format("{0} [R = {1}]",
                                        transform, Math.Round(arrReg[i].GetR_yx1(), 3)));
     }
 }
Exemple #10
0
        void openToolStripMenuItem1_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() != DialogResult.OK)
            {
                return;
            }
            try
            {
                FileStream      fs = new FileStream(openFileDialog1.FileName, FileMode.Open);
                BinaryFormatter bf = new BinaryFormatter();
                arrSmp = (Sample[])bf.Deserialize(fs);
                fs.Close();
                foreach (Sample s in arrSmp)
                {
                    s.DoHistogram(useSturgess);
                }
                arrTranSmp = new TranSample[arrSmp.Length];
                for (int i = 0; i < arrTranSmp.Length; i++)
                {
                    arrTranSmp[i] = new TranSample(this.arrSmp[i], "Нет");
                    arrTranSmp[i].DoHistogram(useSturgess);
                }

                lvSample.Items.Clear();
                lvSample.SuspendLayout();
                foreach (Sample s in arrSmp)
                {
                    lvSample.Items.Add(new ListViewItem(new string[] { s.GetName(), "Нет" }));
                }
                lvSample.ResumeLayout();
            }
            catch
            {
                MessageBox.Show("Ошибка загрузки");
            }
        }