private void Classterizate_Click(object sender, EventArgs e)
        {
            Classter.ChangeD(TypeDComboBox.Text);
            Classter.ChangeDSS(TypeDSSComboBox.Text);

            Classter.VFound(IAM);

            if (MethodComboBox.SelectedIndex == 0)
            {
                if (Classters.Count < 2)
                {
                    return;
                }
                KAverage();
            }
            else if (MethodComboBox.SelectedIndex == 1)
            {
                AdditionalInformationForm AIF = new AdditionalInformationForm("Введіть K");
                int index;
                try
                { index = Convert.ToInt32(AIF.getString()); }
                catch
                { return; }
                AgmomerativClassterizate(index > 1 ? index : 2);
            }

            if (IAM.n == 2)
            {
                chart.Series[0].Enabled = chart.Series[1].Enabled = Classterizate.Visible = false;
            }
            int MaxGroup = -1;

            for (int j = 0; j < ML.Count; j++)
            {
                MaxGroup = Math.Max(MaxGroup, ML[j].Group);
            }
            for (int i = 0; i < Classters.Count; i++)
            {
                InitialStatisticalAnalys[] ISA = Classters[i].ToISA(MaxGroup + i + 1);
                if (IAM.n == 2)
                {
                    chart.Series.Add(
                        PaintData.CorelPaint(ISA[0].unsortl, ISA[1].unsortl, GetColor(i),
                                             "Classter" + (i + 1).ToString()));
                    chart.Series[chart.Series.Count - 1].MarkerSize = 10;
                }
                for (int j = 0; j < ISA.Length; j++)
                {
                    ML.Add(ISA[j]);
                    undolist.Add(ML[ML.Count - 1].unsortl);
                }
            }
            WraitData.RefreshList(treeView1, ML);

            Classter.QFound(Classters.ToArray());
            ShowQ(Classter.Q);
        }
        private void ChangeIndex_Click(object sender, EventArgs e)
        {
            AdditionalInformationForm AIF = new AdditionalInformationForm("Введіть індекс");
            int index;

            try
            { index = Convert.ToInt32(AIF.getString()); }
            catch
            { return; }
            InitializeData(index);
        }
        private void BottomValueToolStripMenuItem_Click(object sender, EventArgs e)
        {
            AdditionalInformationForm AIF = new AdditionalInformationForm("Кількість факторів");
            int DataVariable;

            try
            {
                DataVariable = Convert.ToInt32(AIF.getString());
            }
            catch
            { return; }
            double ee;

            try { ee = Convert.ToDouble(MinimalDispers.Text); }
            catch { ee = 1; }

            int MinW = 0;

            foreach (double val in IAM.eightvalue)
            {
                if (val > 1)
                {
                    MinW++;
                }
            }

            double[,] Xallstandart = new double[IAM.Xall.GetLength(0), IAM.Xall.GetLength(1)];
            for (int i = 0; i < IAM.Xall.GetLength(0); i++)
            {
                for (int j = 0; j < IAM.Xall.GetLength(1); j++)
                {
                    Xallstandart[i, j] = (IAM.Xall[i, j] - IAM.Ex[j]) / IAM.ISA[j].Gx.Q;
                }
            }



            hFound hF = null;

            double[] h;

            double[] eightvalue;
            double[,] eightvector;

            Matrix.OwnVectors(IAM.K, out eightvalue, out eightvector);
            Matrix.SortEighten(ref eightvalue, ref eightvector);
            int w = MinW;

            if (indexMinfFound(eightvector, w) == 0)
            {
                hF += HSquareFound;
            }
            else
            {
                hF += HSquareMaxFound;
            }
            h              = hF(eightvector, w);
            double[,] Rh   = SetRh(IAM.K, h);
            double[,] Rzal = RzalFound(Rh, eightvector);
            double f = fFound(Rzal, w);

            double[,] eightvectorPrev = eightvector;
            double fPrev = f;

            int count = 0;

            for (; count == 0 ||
                 AlfaCheck(eightvector, eightvectorPrev, ee) &&
                 f < fPrev && hCheck(h);
                 count++)
            {
                fPrev           = f;
                eightvectorPrev = eightvector;

                Matrix.OwnVectors(Rh, out eightvalue, out eightvector);
                Matrix.SortEighten(ref eightvalue, ref eightvector);
                w    = Math.Max(WFound(eightvalue), MinW);
                h    = hF(eightvector, w);
                Rh   = SetRh(IAM.K, h);
                Rzal = RzalFound(Rh, eightvector);
                f    = fFound(Rzal, w);
            }

            int MaxGroup = -1;

            for (int j = 0; j < ML.Count; j++)
            {
                MaxGroup = Math.Max(MaxGroup, ML[j].Group);
            }

            DataGridView.Rows.Clear();
            SetData();


            double[] Procent = new double[IAM.n];
            for (int c = 0; c < IAM.n; c++)
            {
                for (int r = 0; r < w; r++)
                {
                    Procent[c] += Math.Pow(eightvector[c, r], 2);
                }
                Procent[c] *= 100;
            }
            w = DataVariable;


            SetFactro(eightvector, w);
        }