Exemplo n.º 1
0
        public MainComponentMethod(InitialAnalysMultidimensionalData IAM,
                                   ref List <InitialStatisticalAnalys> ML, ref List <double[]> undolist, ref TreeView treeView1)
        {
            this.IAM       = IAM;
            this.ML        = ML;
            this.undolist  = undolist;
            this.treeView1 = treeView1;


            DataTabPage = TapPageCreate();
            SetData();

            if (IAM.n == 2)
            {
                Correlation_RegressionAnalysis CRA = new Correlation_RegressionAnalysis(new List <InitialStatisticalAnalys>()
                {
                    IAM.ISA[0], IAM.ISA[1]
                },
                                                                                        new List <int>()
                {
                    0, 1
                }, RegresTypeName.LineRegresion);
                picture.Image = PaintData.Paintf(CRA, picture.Width, picture.Height);
            }
        }
Exemplo n.º 2
0
        private InitialAnalysMultidimensionalData ReversTransform(InitialAnalysMultidimensionalData IAMIndepended, double[,] eightvector)
        {
            double[,] eightvectorClone = new double[eightvector.GetLength(1), IAMIndepended.Xall.GetLength(1)];
            for (int r = 0; r < eightvectorClone.GetLength(0); r++)
            {
                for (int c = 0; c < eightvectorClone.GetLength(1); c++)
                {
                    eightvectorClone[r, c] = eightvector[r, c];
                }
            }
            double[,] X = Matrix.MultiplicMatrix(IAMIndepended.Xall, Matrix.TranspMatrix(eightvectorClone));

            InitialAnalysMultidimensionalData result = new InitialAnalysMultidimensionalData(X, -1);


            if (IAM.n == 2)
            {
                double corel = IAM.K[0, 1];
                double fi    = Math.Atan(2 * corel * IAM.ISA[0].Gx.Q * IAM.ISA[1].Gx.Q /
                                         (Math.Pow(IAM.ISA[0].Gx.Q, 2) - Math.Pow(IAM.ISA[1].Gx.Q, 2))) / 2;
                picture.Image = PaintData.RotateImage(new Bitmap(picture.Image), -fi);
            }

            return(result);
        }
Exemplo n.º 3
0
        public Classterization(InitialAnalysMultidimensionalData IAM,
                               ref List <InitialStatisticalAnalys> ML, ref List <double[]> undolist, ref TreeView treeView1)
        {
            this.IAM       = IAM;
            this.ML        = ML;
            this.undolist  = undolist;
            this.treeView1 = treeView1;

            Data = new List <double[]>();
            for (int i = 0; i < IAM.N; i++)
            {
                double[] value = new double[IAM.n];
                for (int j = 0; j < IAM.n; j++)
                {
                    value[j] = IAM.Xall[i, j];
                }
                Data.Add(value);
            }

            InitializeComponent();
            SetData();

            if (IAM.n == 2)
            {
                chart.Series.Add(PaintData.CorelPaint(IAM.ISA[0].unsortl, IAM.ISA[1].unsortl, Color.Blue, ""));
                chart.Series.Add(ClassterCenterSer);
            }
        }
Exemplo n.º 4
0
 static public void DrawClassters(Chart chart, Classter[] classters)
 {
     for (int i = 0; i < classters.Length; i++)
     {
         chart.Series.Add(PaintData.CorelPaint(classters[i].IAM.ISA[0].unsortl, classters[i].IAM.ISA[1].unsortl,
                                               PaintData.HsvToRgb(360.0 * i / classters.Length, 1, 1), "Класстер: " + (i + 1).ToString()));
     }
 }
Exemplo n.º 5
0
        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 CorelAreachartPaint(InitialAnalysMultidimensionalData IAM, Color CorelCol, Color GistCol, Chart CorelChart, Color ColLine)
        {
            for (int i = 0; i < IAM.n; i++)
            {
                for (int j = 0; j < IAM.n; j++)
                {
                    string    ChartAreaName = j.ToString() + "_" + i.ToString();
                    ChartArea ChartArea1    = new ChartArea(ChartAreaName);
                    ChartArea1.AxisX.LabelStyle.Enabled = false;
                    ChartArea1.AxisY.LabelStyle.Enabled = false;
                    CorelChart.ChartAreas.Add(ChartArea1);
                    var po = CorelAreachart.ChartAreas[0].Position;


                    Series ser;
                    if (i != j)
                    {
                        InitialStatisticalAnalys ISAX = new InitialStatisticalAnalys(InitialStatisticalAnalys.StandData(IAM.ISA[i].unsortl, IAM.ISA[i].Gx.Q, IAM.ISA[i].Mx.Q));
                        InitialStatisticalAnalys ISAY = new InitialStatisticalAnalys(InitialStatisticalAnalys.StandData(IAM.ISA[j].unsortl, IAM.ISA[j].Gx.Q, IAM.ISA[j].Mx.Q));
                        ser             = PaintData.CorelPaint(ISAX.unsortl, ISAY.unsortl, CorelCol, ChartAreaName);
                        ser.MarkerStyle = MarkerStyle.Circle;
                        CorelChart.Series.Add(ser);

                        double Sz = 0;
                        if (Correlation_RegressionAnalysis.KorelationZnach(IAM.K[i, j], IAM.N, IAM.ISA[0].alf.Q))
                        {
                            List <Data> Param = Correlation_RegressionAnalysis.RegresParamFound(
                                ISAX,
                                ISAY,
                                IAM.K[i, j], RegresTypeName.LineRegresion, ref Sz);
                            Series serReg = PaintData.LineRegresPaint(ISAX.Min.Q,
                                                                      ISAX.Max.Q,
                                                                      Param[0].Q,
                                                                      Param[1].Q,
                                                                      ColLine,
                                                                      ChartAreaName + "Line");
                            serReg.ChartArea = ChartAreaName;
                            CorelChart.Series.Add(serReg);
                        }
                    }
                    else
                    {
                        ser = PaintData.GistogPaint(IAM.ISA[i], GistCol, ChartAreaName);
                        CorelChart.Series.Add(ser);
                    }
                    ser.ChartArea = ChartAreaName;
                }
            }
        }
Exemplo n.º 7
0
        private void BottomValueToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try { MinimalDispersValue = Convert.ToDouble(MinimalDispers.Text); }
            catch { MinimalDispersValue = 0; }

            if (IAM.n == 2)
            {
                double corel = IAM.K[0, 1];
                double fi    = Math.Atan(2 * corel * IAM.ISA[0].Gx.Q * IAM.ISA[1].Gx.Q /
                                         (Math.Pow(IAM.ISA[0].Gx.Q, 2) - Math.Pow(IAM.ISA[1].Gx.Q, 2))) / 2;
                picture.Image = PaintData.RotateImage(new Bitmap(picture.Image), fi);
            }
            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*/;
                }
            }
            double[,] X = Matrix.MultiplicMatrix(Xallstandart, IAM.eightvector);


            int MaxGroup = -1;

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

            for (int i = 0; i < IAM.n; i++)
            {
                List <double> Data = new List <double>();
                for (int j = 0; j < IAM.N; j++)
                {
                    Data.Add(X[j, i]);
                }
                InitialStatisticalAnalys ISA = new InitialStatisticalAnalys(Data, MaxGroup + 1);
                if (ISA.Dx.Q >= MinimalDispersValue)
                {
                    ML.Add(ISA);
                    index.Add(ML.Count - 1);
                    undolist.Add(ML[ML.Count - 1].unsortl);
                }
            }
            WraitData.RefreshList(treeView1, ML);
            IAMIndepended         = new InitialAnalysMultidimensionalData(ML, index, -1);
            IAMIndependedToRevers = new InitialAnalysMultidimensionalData(X, 1);
            ReversTransformValueToolStripMenuItem.Visible = true;

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

            DataGridView.Rows.Clear();
            SetData();
            SetNextData();
        }
Exemplo n.º 8
0
        static public void Repaint(InitialStatisticalAnalys gr, InitialStatisticalAnalys gr2, Correlation_RegressionAnalysis CRA, Chart chart1, Chart chart2)
        {
            chart1.ChartAreas[0].AxisX.LabelStyle.Format = "###,##0.000";
            chart1.ChartAreas[0].AxisY.LabelStyle.Format = "###,##0.000";

            chart2.ChartAreas[0].AxisX.LabelStyle.Format = "###,##0.000";
            chart2.ChartAreas[0].AxisY.LabelStyle.Format = "###,##0.000";
            ///++++++++++++++++++++++++++++++++++++++++++++++
            ///GISTOGAMA_PAINT
            ///++++++++++++++++++++++++++++++++++++++++++++++
            chart1.Series.Clear();
            chart2.Series.Clear();

            if (CRA.f == null)
            {
                return;
            }
            chart1.Series.Add(CorelPaint(gr.unsortl, gr2.unsortl, Color.DarkBlue, "f"));
            chart1.ChartAreas[0].AxisX.Minimum  = gr.Min.Q - gr.Len.Q * 0.05;
            chart1.ChartAreas[0].AxisX.Maximum  = gr.Max.Q + gr.Len.Q * 0.05;
            chart1.ChartAreas[0].AxisX.Interval = Math.Round(gr.Len.Q * 0.1, 3);
            chart1.ChartAreas[0].AxisY.Interval = Math.Round(gr2.Len.Q * 0.1, 3);
            chart1.ChartAreas[0].AxisY.Minimum  = gr2.Min.Q - gr2.Len.Q * 0.05;
            chart1.ChartAreas[0].AxisY.Maximum  = gr2.Max.Q + gr2.Len.Q * 0.05;
            chart2.ChartAreas[0].AxisX.Minimum  = chart2.ChartAreas[0].AxisY.Minimum = 0;
            chart2.ChartAreas[0].AxisX.Maximum  = CRA.f.GetLength(0);
            chart2.ChartAreas[0].AxisY.Maximum  = CRA.f.GetLength(1);
            chart2.ChartAreas[0].AxisX.Interval = chart2.ChartAreas[0].AxisY.Interval = 100;

            chart1.Titles[0].Text = "y";
            chart1.Titles[1].Text = "x";
            chart2.Titles[0].Text = "x";
            chart2.Titles[1].Text = "y";

            chart2.ChartAreas[0].AxisY.CustomLabels.Clear();

            /*for (int j = 0; j < CRA.f.GetLength(0); j++)
             * {
             *  string str2 = "";
             *  for (int k = 0; k < CRA.f.GetLength(1); k++)
             *  {
             *      str2 = "f" + j.ToString() + "_" + k.ToString();
             *      chart2.Series.Add(str2);
             *      chart2.Series[str2].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Point;
             *      chart2.Series[str2].MarkerStyle = MarkerStyle.Square;
             *      chart2.Series[str2].IsVisibleInLegend = false;
             *      chart2.Series[str2].MarkerSize = (chart2.Size.Width - 20 + k * 10) / CRA.f.GetLength(0);
             *      //chart2.Series[str2]["PixelPointWidth"] = "200";//PointWidth
             *      double z = CRA.f[j, k];
             *      if (z > 0.07)
             *          chart2.Series[str2].Color = Color.Black;
             *      else
             *      {
             *          int r = 255 - (int)(255 * CRA.f[j, k] / 0.07);
             *          chart2.Series[str2].Color = Color.FromArgb(r, r, r);
             *      }
             *      //chart2.Series[str2].Color = Color.FromArgb(r, r, r);
             *      //chart2.Series[str2]["StackedGroupName"] = "Group" + j.ToString();
             *      chart2.Series[str2].Points.AddXY(j + 0.5,
             *          k + 0.5);
             *  }
             * }*/
            Image      d  = PaintData.Paintf(CRA, 1000, 1000);
            NamedImage ni = new NamedImage("backimage", d);

            chart2.Images.Add(ni);
            chart2.ChartAreas[0].BackImageAlignment = ChartImageAlignmentStyle.Center;
            chart2.ChartAreas[0].BackImageWrapMode  = ChartImageWrapMode.Scaled;
            chart2.ChartAreas[0].BackImage          = "backimage";

            if (CRA.Doubl == true && CRA.Nezal == true)
            {
                chart1.Series.Add("Лін Рег" + ":" + CRA.RegresTypeVib);
                chart1.Series["Лін Рег" + ":" + CRA.RegresTypeVib].ChartType   = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
                chart1.Series["Лін Рег" + ":" + CRA.RegresTypeVib].Color       = Color.Yellow;
                chart1.Series["Лін Рег" + ":" + CRA.RegresTypeVib].BorderWidth = 3;
                if (CRA.RegresTypeVib == RegresTypeName.LineRegresion)
                {
                    //CRA.ABTeil
                    ///teilor
                    chart1.Series.Add("Лін Рег Тейл");
                    chart1.Series["Лін Рег Тейл"].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
                    chart1.Series["Лін Рег Тейл"].Color     = Color.Green;
                    chart1.Series["Лін Рег Тейл"].Points.AddXY(gr.Min.Q, CRA.ABTeil[0] + gr.Min.Q * CRA.ABTeil[1]);
                    chart1.Series["Лін Рег Тейл"].BorderWidth = 3;
                    chart1.Series["Лін Рег Тейл"].Points.AddXY(gr.Max.Q, CRA.ABTeil[0] + gr.Max.Q * CRA.ABTeil[1]);
                }

                chart1.Series.Add("Тол меж");
                chart1.Series["Тол меж"].ChartType   = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
                chart1.Series["Тол меж"].Color       = Color.DarkRed;
                chart1.Series["Тол меж"].BorderWidth = 2;
                chart1.Series.Add("Тол меж2");
                chart1.Series["Тол меж2"].ChartType         = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
                chart1.Series["Тол меж2"].Color             = chart1.Series["Тол меж"].Color;
                chart1.Series["Тол меж2"].IsVisibleInLegend = false;
                chart1.Series["Тол меж2"].BorderWidth       = 2;

                chart1.Series.Add("Дов інтр");
                chart1.Series["Дов інтр"].ChartType   = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
                chart1.Series["Дов інтр"].Color       = Color.DarkMagenta;
                chart1.Series["Дов інтр"].BorderWidth = 2;
                chart1.Series.Add("Дов інтр2");
                chart1.Series["Дов інтр2"].ChartType         = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line;
                chart1.Series["Дов інтр2"].Color             = chart1.Series["Дов інтр"].Color;
                chart1.Series["Дов інтр2"].IsVisibleInLegend = false;
                chart1.Series["Дов інтр2"].BorderWidth       = 2;
                if (CRA.RegresTypeVib != RegresTypeName.ParabRegresion)
                {
                    for (double x0 = gr.Min.Q; x0 <= gr.Max.Q; x0 += gr.Len.Q * 0.005)
                    {
                        double Sx0 = Math.Sqrt(CRA.Szal * (1 + 1.0 / gr.l.Count) + CRA.Q[1].QSigma * Math.Pow(x0 - gr.Mx.Q, 2));
                        if (CRA.RegresTypeVib == RegresTypeName.LineRegresion)
                        {
                            chart1.Series["Дов інтр"].Points.AddXY(x0, RegresType.Model(x0, CRA.Q, CRA.RegresTypeVib) - CRA.T * Sx0);
                            chart1.Series["Дов інтр2"].Points.AddXY(x0, RegresType.Model(x0, CRA.Q, CRA.RegresTypeVib) + CRA.T * Sx0);
                        }
                        chart1.Series["Тол меж"].Points.AddXY(x0, RegresType.Model(x0, CRA.Q, CRA.RegresTypeVib) - CRA.T * CRA.Szal);
                        chart1.Series["Тол меж2"].Points.AddXY(x0, RegresType.Model(x0, CRA.Q, CRA.RegresTypeVib) + CRA.T * CRA.Szal);
                    }
                    for (double x0 = gr.Min.Q; x0 <= gr.Max.Q; x0 += gr.Len.Q * 0.005)
                    {
                        chart1.Series["Лін Рег" + ":" + CRA.RegresTypeVib].Points.AddXY(x0, RegresType.Model(x0, CRA.Q, CRA.RegresTypeVib));
                    }
                }
                else if (CRA.RegresTypeVib == RegresTypeName.ParabRegresion)
                {
                    double x2 = InitialStatisticalAnalys.StartMoment(gr.l, 2);
                    double x3 = InitialStatisticalAnalys.StartMoment(gr.l, 3);
                    double x4 = InitialStatisticalAnalys.StartMoment(gr.l, 4);
                    double Tt = Distributions.StudentQuantile(1 - gr.alf.Q / 2, gr.unsortl.Length - 3);
                    for (double x0 = gr.Min.Q; x0 <= gr.Max.Q; x0 += gr.Len.Q * 0.005)
                    {
                        double Sx0 = Math.Sqrt(Math.Pow(CRA.Szal2, 2) * (1 + 1.0 / gr.l.Count) +
                                               Math.Pow(CRA.Q[4].QSigma * Correlation_RegressionAnalysis.fi1F(x0, gr.Mx.Q), 2) +
                                               Math.Pow(CRA.Q[5].QSigma * Correlation_RegressionAnalysis.fi2F(x0, gr.Dx.Q, gr.Mx.Q, x2, x3), 2));

                        /*
                         * chart1.Series["Дов інтр"].Points.AddXY(x0, RegresType.Model(x0, CRA.Q, CRA.RegresTypeVib) - CRA.T * Sx0);
                         * chart1.Series["Дов інтр2"].Points.AddXY(x0, RegresType.Model(x0, CRA.Q, CRA.RegresTypeVib) + CRA.T * Sx0);*/

                        chart1.Series["Дов інтр"].Points.AddXY(x0, CRA.Q[3].Q + CRA.Q[4].Q * Correlation_RegressionAnalysis.fi1F(x0, gr.Mx.Q)
                                                               + CRA.Q[5].Q * Correlation_RegressionAnalysis.fi2F(x0, gr.Dx.Q, gr.Mx.Q, x2, x3)
                                                               - Tt * Sx0);
                        chart1.Series["Дов інтр2"].Points.AddXY(x0, CRA.Q[3].Q + CRA.Q[4].Q * Correlation_RegressionAnalysis.fi1F(x0, gr.Mx.Q)
                                                                + CRA.Q[5].Q * Correlation_RegressionAnalysis.fi2F(x0, gr.Dx.Q, gr.Mx.Q, x2, x3)
                                                                + Tt * Sx0);


                        chart1.Series["Тол меж"].Points.AddXY(x0, CRA.Q[3].Q + CRA.Q[4].Q * Correlation_RegressionAnalysis.fi1F(x0, gr.Mx.Q)
                                                              + CRA.Q[5].Q * Correlation_RegressionAnalysis.fi2F(x0, gr.Dx.Q, gr.Mx.Q, x2, x3)
                                                              - Tt * CRA.Szal2);
                        chart1.Series["Тол меж2"].Points.AddXY(x0, CRA.Q[3].Q + CRA.Q[4].Q * Correlation_RegressionAnalysis.fi1F(x0, gr.Mx.Q)
                                                               + CRA.Q[5].Q * Correlation_RegressionAnalysis.fi2F(x0, gr.Dx.Q, gr.Mx.Q, x2, x3)
                                                               + Tt * CRA.Szal2);
                    }
                    for (double x0 = gr.Min.Q; x0 <= gr.Max.Q; x0 += gr.Len.Q * 0.005)
                    {
                        chart1.Series["Лін Рег" + ":" + CRA.RegresTypeVib].Points.AddXY(x0, CRA.Q[3].Q + CRA.Q[4].Q * Correlation_RegressionAnalysis.fi1F(x0, gr.Mx.Q)
                                                                                        + CRA.Q[5].Q * Correlation_RegressionAnalysis.fi2F(x0, gr.Dx.Q, gr.Mx.Q, x2, x3));
                    }
                }
            }
        }