Esempio n. 1
0
        private void HToolStripMenuItem_Click(object sender, EventArgs e)
        {
            bool[] KTurnOn = KTurnOnFound();
            int    w       = 0;

            foreach (bool b in KTurnOn)
            {
                if (!b)
                {
                    w++;
                }
            }
            double[,] SubK = InitialAnalysMultidimensionalData.SubK(IAM.K, KTurnOn);
            double[,] T    = TFound(SubK, KTurnOn);
            double T_alf_v = Distributions.StudentQuantile(1 - IAM.ISA[0].alf.Q / 2, IAM.N - w - 2);

            bool[,] H = new bool[T.GetLength(0), T.GetLength(1)];
            for (int i = 0; i < H.GetLength(0); i++)
            {
                for (int j = 0; j < H.GetLength(1); j++)
                {
                    if (Math.Abs(T[i, j]) <= T_alf_v)
                    {
                        H[i, j] = true;
                    }
                }
            }
            WraitH(CorelDataGridView, H, KTurnOn);
        }
        static public bool KorelationZnach(double Korelation, int N, double alf)
        {
            bool   Znach = false;
            double T     = Korelation * Math.Sqrt((N - 2) / (1 - Math.Pow(Korelation, 2)));
            double TQv   = Distributions.StudentQuantile(1 - alf / 2, N - 2);

            Znach = Math.Abs(T) <= TQv;
            return(!Znach);
        }
Esempio n. 3
0
        private void CorelatioDataGridView_ColumnHeaderMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e)
        {
            bool[] b    = new bool[CorelDataGridView.ColumnCount];
            int    size = 0;

            for (int i = 0; i < CorelDataGridView.ColumnCount; i++)
            {
                if (CorelDataGridView[i, i].Style.BackColor != Color.Red)
                {
                    size++;
                    b[i] = true;
                }
            }
            if (CorelDataGridView[e.ColumnIndex, 0].Style.BackColor != Color.Red)
            {
                b[e.ColumnIndex] = false;
                size--;
                if (size < 2)
                {
                    return;
                }
                for (int i = 0; i < CorelDataGridView.ColumnCount; i++)
                {
                    CorelDataGridView[i, e.ColumnIndex].Style.BackColor = Color.Red;
                    CorelDataGridView[e.ColumnIndex, i].Style.BackColor = Color.Red;
                    CorelDataGridView[i, e.ColumnIndex].Value           = "";
                    CorelDataGridView[e.ColumnIndex, i].Value           = "";
                }
            }
            else
            {
                b[e.ColumnIndex] = true;
                size++;
                for (int i = 0; i < CorelDataGridView.ColumnCount; i++)
                {
                    if (b[i])
                    {
                        CorelDataGridView[i, e.ColumnIndex].Style.BackColor = Color.Green;
                        CorelDataGridView[e.ColumnIndex, i].Style.BackColor = Color.Green;
                    }
                }
            }
            CorelDataGridView.TopLeftHeaderCell.Value
                           = Math.Round(Distributions.StudentQuantile(1 - IAM.ISA[0].alf.Q / 2, IAM.N - (b.Length - size) - 2), 4).ToString();
            double[,] SubK = InitialAnalysMultidimensionalData.SubK(IAM.K, b);
            WraitK(CorelDataGridView, SubK, b);
        }
        public void Refresh()
        {
            Min.Q = l[0];
            Max.Q = l[l.Count - 1];
            Len.Q = Max.Q - Min.Q;
            T     = Distributions.StudentQuantile(alf.Q / 2, (int)m.Q - 1);
            f     = new List <double>();
            Y2    = new List <double>();
            F     = new List <double>();
            if (l[l.Count - 1] - l[0] == 0)
            {
                Step.Q = 1;
            }
            else
            {
                Step.Q = 1.0001 * ((l[l.Count - 1] - l[0]) / m.Q);
            }
            MxFound(l);
            DxFound();
            X_2.Q     = StartMoment(l, 2);
            Mx_rang.Q = Mx.Q - (l[0] + l[l.Count - 1]) / l.Count;
            Mediana.Q = MEDFound(l);
            MADFound();
            MODFound();
            CoefEcscecFound(l);
            CoefAsimFound(l);
            QuantileFound();
            //AverYolshaFound();
            CutData();
            CoefVarPirson.Q = Gx.Q / Mx.Q;
            W.Q             = MAD.Q / Mediana.Q;
            PredictionintervalFound(l);
            A             = Mx.Q - Math.Sqrt(3 * (X_2.Q - Mx.Q * Mx.Q));
            B             = Mx.Q + Math.Sqrt(3 * (X_2.Q - Mx.Q * Mx.Q));
            KrAbbe.Q      = KrAbbeFound(l, unsortl);
            KrAbbe.QKvant = Distributions.NormalQuantile(1 - alf.Q / 2);

            DataRound();
        }
Esempio n. 5
0
        public UniformityCriteria(List <InitialStatisticalAnalys> ML, List <int> MSelectGR)
        {
            this.ML        = ML;
            this.MSelectGR = MSelectGR;

            N = NFound(ML, MSelectGR);
            {
                double NezCount = ML[MSelectGR[0]].l.Count;
                for (int i = 0; i < MSelectGR.Count; i++)
                {
                    if (ML[MSelectGR[i]].l.Count != NezCount)
                    {
                        Nezal = false;
                    }
                }
            }
            rDvomFound(ML[MSelectGR[0]].unsortl);
            r            = rFound(ML, MSelectGR);
            Sm2          = Sm2Found(ML, MSelectGR);
            Sv2          = Sv2Found(ML, MSelectGR);
            VarSv2Sm2[0] = Sm2 / Sv2;
            VarSv2Sm2[1] = Distributions.FisherQuantile(ML[MSelectGR[0]].alf.Q, MSelectGR.Count - 1, (int)(N - MSelectGR.Count));
            var tyui = Distributions.FisherQuantile(ML[MSelectGR[0]].alf.Q, 10, 10);

            if (Nezal == true)
            {
                KrKohrena[0] = KrKohrenaFound(ML, MSelectGR);
                KrKohrena[1] = Hi.HIF(ML[MSelectGR[0]].alf.Q, MSelectGR.Count - 1);
                T            = Distributions.StudentQuantile(1 - ML[MSelectGR[0]].alf.Q / 2, ML[MSelectGR[0]].l.Count - 2);
            }
            if (MSelectGR.Count == 2)
            {
                Doubl = true;
                if (Nezal == true)
                {
                    SravnSred[1] = Distributions.StudentQuantile(ML[MSelectGR[0]].alf.Q / 2,
                                                                 ML[MSelectGR[0]].l.Count + ML[MSelectGR[1]].l.Count - 2);
                }
                else
                {
                    SravnSred[1] = Distributions.StudentQuantile(ML[MSelectGR[0]].alf.Q / 2, ML[MSelectGR[0]].l.Count - 2);
                }

                SravnSred[0]   = SimpleMx(ML[MSelectGR[0]], ML[MSelectGR[1]]);
                SravnDisper[0] = SimpleS(ML[MSelectGR[0]], ML[MSelectGR[1]]);
                SravnDisper[1] = Distributions.FisherQuantile(ML[MSelectGR[0]].alf.Q, ML[MSelectGR[0]].l.Count - 1, ML[MSelectGR[1]].l.Count - 1);

                KrSmirnKolmag[0] = 1.0 - LzFound(ZFound(ML[MSelectGR[0]], ML[MSelectGR[1]]));
                KrSmirnKolmag[1] = ML[MSelectGR[0]].alf.Q;

                KrsumRangVils[0] = KrsumRangVilsFound(r, ML[MSelectGR[0]], ML[MSelectGR[1]]);
                KrsumRangVils[1] = Distributions.NormalQuantile(1 - ML[MSelectGR[0]].alf.Q / 2.0);

                KrUMannaUit[0] = KrUMannaUitFound(ML[MSelectGR[0]], ML[MSelectGR[1]]);
                KrUMannaUit[1] = Distributions.NormalQuantile(1 - ML[MSelectGR[0]].alf.Q / 2.0);

                RizSerRangVib[0] = RizSerRangVibFound(r, ML[MSelectGR[0]], ML[MSelectGR[1]]);
                RizSerRangVib[1] = Distributions.NormalQuantile(1 - ML[MSelectGR[0]].alf.Q / 2.0);

                KrZnakiv[0] = KrZnakivFound(ML[MSelectGR[0]], ML[MSelectGR[1]]);
            }
            else
            {
                Doubl          = false;
                SravnSred[0]   = SimpleMx(ML, MSelectGR);
                SravnDisper[0] = SimpleS(ML, MSelectGR);
                SravnDisper[1] = Hi.HIF(ML[MSelectGR[0]].alf.Q, MSelectGR.Count - 1);

                KrKruskalaUolisa[0] = KrKruskalaUolisaFound(r, ML, MSelectGR);
                KrKruskalaUolisa[1] = Hi.HIF(ML[MSelectGR[0]].alf.Q, MSelectGR.Count - 1);
            }
            Round();
        }
Esempio n. 6
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));
                    }
                }
            }
        }
        public Correlation_RegressionAnalysis(List <InitialStatisticalAnalys> ML, List <int> MSelectGR, string RegresTypeVib)
        {
            this.ML            = ML;
            this.MSelectGR     = MSelectGR;
            this.RegresTypeVib = RegresTypeVib;

            N = NFound(ML, MSelectGR);
            {
                double NezCount = ML[MSelectGR[0]].l.Count;
                for (int i = 0; i < MSelectGR.Count; i++)
                {
                    if (ML[MSelectGR[i]].l.Count != NezCount)
                    {
                        Nezal = false;
                    }
                }
            }
            T = Distributions.StudentQuantile(1 - ML[MSelectGR[0]].alf.Q / 2, ML[MSelectGR[0]].l.Count - 2);
            if (MSelectGR.Count == 2)
            {
                Doubl = true;
                if (Nezal == true)
                {
                    f                   = fFound(ML[MSelectGR[0]], ML[MSelectGR[1]], 15, 7);
                    Korelation[0]       = KorelationFound(ML[MSelectGR[0]], ML[MSelectGR[1]]);
                    KorelationVidnoh[0] = KorelationVidnohFound(ML, MSelectGR);
                    RangKorelation[0]   = RangKorelationFound(ML, MSelectGR);
                    RangKorelation[1]   = RangKorelation[0] * Math.Sqrt((ML[MSelectGR[0]].l.Count - 2) / (1 - Math.Pow(RangKorelation[0], 2)));


                    X2f[0] = X2fFound(ML[MSelectGR[0]], ML[MSelectGR[1]], f);
                    X2f[1] = Hi.HIF(ML[MSelectGR[0]].alf.Q, ML[MSelectGR[0]].l.Count - 2);

                    RangKoefKend[0] = RangKoefKendFound(ML, MSelectGR);//slow
                    RangKoefKend[1] = 3 * RangKoefKend[0] * Math.Sqrt((ML[MSelectGR[0]].l.Count * (ML[MSelectGR[0]].l.Count - 1)) /
                                                                      (2 * (2 * ML[MSelectGR[0]].l.Count + 5)));
                    RangKoefKend[2] = Distributions.NormalQuantile(1 - ML[MSelectGR[0]].alf.Q / 2);

                    Nij = NijFound(ML, MSelectGR);
                    int ti = (int)(12 * ML[MSelectGR[1]].Dx.Q / ML[MSelectGR[0]].Dx.Q);
                    try
                    {
                        if (Math.Abs(ti) > 20)
                        {
                            ti = 20;
                        }
                    }
                    catch
                    { ti = 20; }
                    TablPerTab(ML, MSelectGR, fFound(ML[MSelectGR[0]], ML[MSelectGR[1]], 12, ti));

                    Q    = RegresParamFound(ML[MSelectGR[0]], ML[MSelectGR[1]], Korelation[0], RegresTypeVib, ref Szal2);
                    Szal = SzalF(ML[MSelectGR[0]], ML[MSelectGR[1]], Q, RegresTypeVib);/*
                                                                                        * AB[1] = Korelation[0] * ML[MSelectGR[1]].Gx.Q / ML[MSelectGR[0]].Gx.Q;
                                                                                        * AB[0] = ML[MSelectGR[1]].Mx.Q - AB[1] * ML[MSelectGR[0]].Mx.Q;*/
                    NachYslovRegAnal(ML[MSelectGR[0]], ML[MSelectGR[1]]);
                    // Szal = SzalFound(AB, ML[MSelectGR[0]], ML[MSelectGR[1]]);

                    /*AB[2] = Szal * Math.Sqrt(1.0 / ML[MSelectGR[0]].l.Count + Math.Pow(ML[MSelectGR[0]].Mx.Q, 2) /
                     *  (ML[MSelectGR[0]].Dx.Q * (ML[MSelectGR[0]].l.Count - 1)));
                     * AB[3] = Szal / (ML[MSelectGR[0]].Gx.Q * Math.Sqrt(ML[MSelectGR[0]].l.Count - 1));*/


                    ABTailFound(ML[MSelectGR[0]], ML[MSelectGR[1]]);
                    double op = Korelation[0] * (1 - Math.Pow(Korelation[0], 2)) / (2 * ML[MSelectGR[0]].l.Count);
                    double oi = (1 - Math.Pow(Korelation[0], 2)) / Math.Sqrt(ML[MSelectGR[0]].l.Count - 1);
                    double rn = Korelation[0] + op - Distributions.NormalQuantile(1 - ML[MSelectGR[0]].alf.Q / 2) * oi;
                    double rv = Korelation[0] + op + Distributions.NormalQuantile(1 - ML[MSelectGR[0]].alf.Q / 2) * oi;
                    if (rn < -1)
                    {
                        rn = 1;
                    }
                    if (rv > 1)
                    {
                        rv = 1;
                    }
                    Korelation[1] = rn;
                    Korelation[2] = rv;
                    Korelation[3] = op;
                    if (RegresTypeVib == RegresTypeName.ParabRegresion)
                    {
                        KoefDeterm = (1 - Math.Pow(Szal2, 2) / ML[MSelectGR[1]].Dx.Q) * 100;
                    }
                    else
                    {
                        KoefDeterm = Math.Pow(Korelation[0], 2) * 100;
                    }
                }
            }
            else
            {
                Doubl = false;
            }
            Round();
        }
        static public List <Data> RegresParamFound(InitialStatisticalAnalys ISAX, InitialStatisticalAnalys ISAY, double Korelation, string TypeRegVib, ref double Szal2)
        {
            List <Data> Qm = new List <Data>();

            if (TypeRegVib == RegresTypeName.ParabRegresion)
            {
                Data a = new Data(), b = new Data(), c = new Data();
                Qm.Add(a);
                Qm.Add(b);
                Qm.Add(c);
                a.Name = "a";
                b.Name = "b";
                c.Name = "c";
                double n1 = 0;//107 page andan
                double x2 = InitialStatisticalAnalys.StartMoment(ISAX.l, 2);
                double x3 = InitialStatisticalAnalys.StartMoment(ISAX.l, 3);
                double x4 = InitialStatisticalAnalys.StartMoment(ISAX.l, 4);
                for (int i = 0; i < ISAX.unsortl.Length; i++)
                {
                    n1 += (ISAY.unsortl[i] - ISAY.Mx.Q) * (Math.Pow(ISAX.unsortl[i], 2) - x2);
                }
                n1  /= ISAX.unsortl.Length;
                c.Q  = ISAX.Dx.Q * n1 - (x3 - x2 * ISAX.Mx.Q) * Korelation * ISAX.Gx.Q * ISAY.Gx.Q;
                c.Q /= ISAX.Dx.Q * (x4 - Math.Pow(x2, 2)) - Math.Pow(x3 - x2 * ISAX.Mx.Q, 2);
                b.Q  = (x4 - Math.Pow(x2, 2)) * Korelation * ISAX.Gx.Q * ISAY.Gx.Q - (x3 - x2 * ISAX.Mx.Q) * n1;
                b.Q /= ISAX.Dx.Q * (x4 - Math.Pow(x2, 2)) - Math.Pow(x3 - x2 * ISAX.Mx.Q, 2);
                a.Q  = ISAY.Mx.Q - b.Q * ISAX.Mx.Q - c.Q * ISAX.X_2.Q;
                Data a2 = new Data(), b2 = new Data(), c2 = new Data();
                Qm.Add(a2);
                Qm.Add(b2);
                Qm.Add(c2);
                a2.Name = "a2";
                b2.Name = "b2";
                c2.Name = "c2";
                a2.Q    = ISAY.Mx.Q;
                double Mfi2scv = 0;
                {
                    double TD = 0;
                    for (int i = 0; i < ISAX.l.Count; i++)
                    {
                        Mfi2scv += Math.Pow(fi2F(ISAX.unsortl[i], ISAX.Dx.Q, ISAX.Mx.Q, x2, x3), 2);
                        b2.Q    += (ISAX.unsortl[i] - ISAX.Mx.Q) * ISAY.unsortl[i];
                        c2.Q    += fi2F(ISAX.unsortl[i], ISAX.Dx.Q, ISAX.Mx.Q, x2, x3) * ISAY.unsortl[i];
                        TD      += Math.Pow(fi2F(ISAX.unsortl[i], ISAX.Dx.Q, ISAX.Mx.Q, x2, x3), 2);
                    }
                    c2.Q /= TD;
                }
                Mfi2scv /= ISAX.l.Count;
                b2.Q    /= ISAX.l.Count;
                b2.Q    /= ISAX.Dx.Q;
                Szal2    = 0;
                for (int i = 0; i < ISAX.l.Count; i++)
                {
                    Szal2 += Math.Pow(ISAY.unsortl[i] - a2.Q - b2.Q * fi1F(ISAX.unsortl[i], ISAX.Mx.Q) - c2.Q * fi2F(ISAX.unsortl[i], ISAX.Dx.Q, ISAX.Mx.Q, x2, x3), 2);
                }
                Szal2    /= ISAX.l.Count - 3;
                Szal2     = Math.Sqrt(Szal2);
                a2.QSigma = Szal2 / Math.Sqrt(ISAX.unsortl.Length);
                b2.QSigma = Szal2 / (ISAX.Dx.Q * Math.Sqrt(ISAX.unsortl.Length));
                c2.QSigma = Szal2 / Math.Sqrt(ISAX.unsortl.Length * Mfi2scv);
                double Tt = Distributions.StudentQuantile(1 - ISAX.alf.Q / 2, ISAX.unsortl.Length - 3);
                a2.QButton = a2.Q - Tt * a2.QSigma;
                a2.QUpper  = a2.Q + Tt * a2.QSigma;
                b2.QButton = b2.Q - Tt * b2.QSigma;
                b2.QUpper  = b2.Q + Tt * b2.QSigma;
                c2.QButton = c2.Q - Tt * c2.QSigma;
                c2.QUpper  = c2.Q + Tt * c2.QSigma;
                double at = ISAY.Mx.Q - b.Q * ISAX.Mx.Q - c.Q * Math.Pow(ISAX.Mx.Q, 2) - a.Q;
                Data   ta = new Data(), tb = new Data(), tc = new Data();
            }
            else
            {
                Data a = new Data(), b = new Data();
                Qm.Add(a);
                Qm.Add(b);
                a.Name = "a";
                b.Name = "b";
                List <double> t = new List <double>();
                List <double> z = new List <double>();
                for (int i = 0; i < ISAX.unsortl.Length; i++)
                {
                    t.Add(RegresType.FiX(ISAX.unsortl[i], TypeRegVib));
                    z.Add(RegresType.FiY(ISAY.unsortl[i], ISAX.unsortl[i], TypeRegVib));
                }

                /*double Mfx = 0,Mfxfx=0, Mfy = 0, Mfxfy = 0,W = 0;
                 * for (int i = 0; i < ISAX.unsortl.Length; i++)
                 * {
                 *  Mfx += RegresType.FiX(ISAX.unsortl[i], TypeRegVib) *
                 *      RegresType.W(ISAY.unsortl[i], ISAX.unsortl[i], TypeRegVib);
                 *  Mfxfx += Math.Pow(RegresType.FiX(ISAX.unsortl[i], TypeRegVib),2) *
                 *      RegresType.W(ISAY.unsortl[i], ISAX.unsortl[i], TypeRegVib);
                 *  Mfy += RegresType.FiY(ISAY.unsortl[i], ISAX.unsortl[i], TypeRegVib) *
                 *      RegresType.W(ISAY.unsortl[i], ISAX.unsortl[i], TypeRegVib);
                 *  Mfxfy += RegresType.FiX(ISAX.unsortl[i], TypeRegVib) * RegresType.FiY(ISAY.unsortl[i], ISAX.unsortl[i], TypeRegVib) *
                 *      RegresType.W(ISAY.unsortl[i], ISAX.unsortl[i], TypeRegVib);
                 *  W += RegresType.W(ISAY.unsortl[i], ISAX.unsortl[i], TypeRegVib);
                 *
                 * }
                 * Mfx /= W;
                 * Mfxfx /= W;
                 * Mfxfy /= W;
                 * Mfy /= W;*/
                // Qm[1].Q = (Mfxfy - Mfx * Mfy) / (Mfxfx - Math.Pow(Mfx, 2));
                //Qm[0].Q = Mfy - Qm[1].Q * Mfx;
                InitialStatisticalAnalys ISAt = new InitialStatisticalAnalys(t);
                InitialStatisticalAnalys ISAz = new InitialStatisticalAnalys(z);
                double Kor_tz = Correlation_RegressionAnalysis.KorelationFound(ISAt, ISAz);
                Qm[1].Q = Kor_tz * ISAz.Gx.Q / ISAt.Gx.Q;
                Qm[0].Q = RegresType.A(ISAz.Mx.Q - Qm[1].Q * ISAt.Mx.Q, TypeRegVib);
                double Szal = SzalF(ISAX, ISAY, Qm, TypeRegVib);
                Qm[0].QSigma  = RegresType.A(Szal * Math.Sqrt(1.0 / ISAX.unsortl.Length + Math.Pow(ISAt.Mx.Q, 2) / (ISAt.Dx.Q * (ISAX.unsortl.Length - 1))), TypeRegVib);
                Qm[1].QSigma  = Szal / (ISAX.unsortl.Length - 1);
                Qm[0].QButton = RegresType.A(Qm[0].Q - Distributions.StudentQuantile(1 - ISAX.alf.Q / 2, ISAX.unsortl.Length - 2) * Qm[0].QSigma, TypeRegVib);
                Qm[0].QUpper  = RegresType.A(Qm[0].Q + Distributions.StudentQuantile(1 - ISAX.alf.Q / 2, ISAX.unsortl.Length - 2) * Qm[0].QSigma, TypeRegVib);
                Qm[1].QButton = Qm[1].Q - Distributions.StudentQuantile(1 - ISAX.alf.Q / 2, ISAX.unsortl.Length - 2) * Qm[1].QSigma;
                Qm[1].QUpper  = Qm[1].Q + Distributions.StudentQuantile(1 - ISAX.alf.Q / 2, ISAX.unsortl.Length - 2) * Qm[1].QSigma;
            }
            return(Qm);
        }
Esempio n. 9
0
        public SimpleClass(List <InitialStatisticalAnalys> ML, List <int> MSelectGR, double BinSim)
        {
            this.ML        = ML;
            this.MSelectGR = MSelectGR;

            N     = NFound(ML, MSelectGR);
            Nezal = Nezalegni();

            r            = rFound(ML, MSelectGR);
            Sm2          = Sm2Found(ML, MSelectGR);
            Sv2          = Sv2Found(ML, MSelectGR);
            VarSv2Sm2[0] = Sm2 / Sv2;
            VarSv2Sm2[1] = Distributions.FisherQuantile(ML[MSelectGR[0]].alf.Q, MSelectGR.Count - 1, (int)(N - MSelectGR.Count));
            var tyui = Distributions.FisherQuantile(ML[MSelectGR[0]].alf.Q, 10, 10);

            if (Nezal == true)
            {
                KrKohrena[0] = KrKohrenaFound(ML, MSelectGR, BinSim);
                KrKohrena[1] = Hi.HIF(ML[MSelectGR[0]].alf.Q, MSelectGR.Count - 1);
                T            = Distributions.StudentQuantile(1 - ML[MSelectGR[0]].alf.Q / 2, ML[MSelectGR[0]].l.Count - 2);
            }
            if (MSelectGR.Count == 2)
            {
                Doubl = true;
                if (Nezal == true)
                {
                    f                   = fFound(ML[MSelectGR[0]], ML[MSelectGR[1]], 15, 7);
                    Korelation[0]       = KorelationFound(ML, MSelectGR);
                    KorelationVidnoh[0] = KorelationVidnohFound(ML, MSelectGR);
                    RangKorelation[0]   = RangKorelationFound(ML, MSelectGR);
                    RangKorelation[1]   = RangKorelation[0] * Math.Sqrt((ML[MSelectGR[0]].l.Count - 2) / (1 - Math.Pow(RangKorelation[0], 2)));


                    X2f[0] = X2fFound(ML[MSelectGR[0]], ML[MSelectGR[1]], f);
                    X2f[1] = Hi.HIF(ML[MSelectGR[0]].alf.Q, ML[MSelectGR[0]].l.Count - 2);

                    RangKoefKend[0] = RangKoefKendFound(ML, MSelectGR);//slow
                    RangKoefKend[1] = 3 * RangKoefKend[0] * Math.Sqrt((ML[MSelectGR[0]].l.Count * (ML[MSelectGR[0]].l.Count - 1)) /
                                                                      (2 * (2 * ML[MSelectGR[0]].l.Count + 5)));
                    RangKoefKend[2] = Distributions.NormalQuantile(1 - ML[MSelectGR[0]].alf.Q / 2);

                    Nij = NijFound(ML, MSelectGR, BinSim);
                    int ti = (int)(12 * ML[MSelectGR[1]].Dx.Q / ML[MSelectGR[0]].Dx.Q);
                    try
                    {
                        if (Math.Abs(ti) > 20)
                        {
                            ti = 20;
                        }
                    }
                    catch
                    { ti = 20; }
                    TablPerTab(ML, MSelectGR, fFound(ML[MSelectGR[0]], ML[MSelectGR[1]], 12, ti));

                    RegresParam = RegresParamFound();
                    NachYslovRegAnal(ML[MSelectGR[0]], ML[MSelectGR[1]]);
                    KoefDeterm = Math.Pow(Korelation[0], 2) * 100;
                    Szal       = SzalFound(AB, ML[MSelectGR[0]], ML[MSelectGR[1]]);
                    AB[2]      = Szal * Math.Sqrt(1.0 / ML[MSelectGR[0]].l.Count + Math.Pow(ML[MSelectGR[0]].Mx.Q, 2) /
                                                  (ML[MSelectGR[0]].Dx.Q * (ML[MSelectGR[0]].l.Count - 1)));
                    AB[3] = Szal / (ML[MSelectGR[0]].Gx.Q * Math.Sqrt(ML[MSelectGR[0]].l.Count - 1));

                    ABTailFound(ML[MSelectGR[0]], ML[MSelectGR[1]]);
                    double op = Korelation[0] * (1 - Math.Pow(Korelation[0], 2)) / (2 * ML[MSelectGR[0]].l.Count);
                    double oi = (1 - Math.Pow(Korelation[0], 2)) / Math.Sqrt(ML[MSelectGR[0]].l.Count - 1);
                    double rn = Korelation[0] + op - Distributions.NormalQuantile(1 - ML[MSelectGR[0]].alf.Q / 2) * oi;
                    double rv = Korelation[0] + op + Distributions.NormalQuantile(1 - ML[MSelectGR[0]].alf.Q / 2) * oi;
                    if (rn < -1)
                    {
                        rn = 1;
                    }
                    if (rv > 1)
                    {
                        rv = 1;
                    }
                    Korelation[1] = rn;
                    Korelation[2] = rv;
                    Korelation[2] = op;
                    SravnSred[1]  = Distributions.StudentQuantile(ML[MSelectGR[0]].alf.Q / 2,
                                                                  ML[MSelectGR[0]].l.Count + ML[MSelectGR[1]].l.Count - 2);
                }
                else
                {
                    SravnSred[1] = Distributions.StudentQuantile(ML[MSelectGR[0]].alf.Q / 2, ML[MSelectGR[0]].l.Count - 2);
                }

                SravnSred[0]   = SimpleMx(ML[MSelectGR[0]], ML[MSelectGR[1]]);
                SravnDisper[0] = SimpleS(ML[MSelectGR[0]], ML[MSelectGR[1]]);
                SravnDisper[1] = Distributions.FisherQuantile(ML[MSelectGR[0]].alf.Q, ML[MSelectGR[0]].l.Count - 1, ML[MSelectGR[1]].l.Count - 1);

                KrSmirnKolmag[0] = 1.0 - LzFound(ZFound(ML[MSelectGR[0]], ML[MSelectGR[1]]));
                KrSmirnKolmag[1] = ML[MSelectGR[0]].alf.Q;

                KrsumRangVils[0] = KrsumRangVilsFound(r, ML[MSelectGR[0]], ML[MSelectGR[1]]);
                KrsumRangVils[1] = Distributions.NormalQuantile(1 - ML[MSelectGR[0]].alf.Q / 2.0);

                KrUMannaUit[0] = KrUMannaUitFound(ML[MSelectGR[0]], ML[MSelectGR[1]]);
                KrUMannaUit[1] = Distributions.NormalQuantile(1 - ML[MSelectGR[0]].alf.Q / 2.0);

                RizSerRangVib[0] = RizSerRangVibFound(r, ML[MSelectGR[0]], ML[MSelectGR[1]]);
                RizSerRangVib[1] = Distributions.NormalQuantile(1 - ML[MSelectGR[0]].alf.Q / 2.0);

                KrZnakiv[0] = KrZnakivFound(ML[MSelectGR[0]], ML[MSelectGR[1]]);
            }
            else
            {
                Doubl          = false;
                SravnSred[0]   = SimpleMx(ML, MSelectGR);
                SravnDisper[0] = SimpleS(ML, MSelectGR);
                SravnDisper[1] = Hi.HIF(ML[MSelectGR[0]].alf.Q, MSelectGR.Count - 1);

                KrKruskalaUolisa[0] = KrKruskalaUolisaFound(r, ML, MSelectGR);
                KrKruskalaUolisa[1] = Hi.HIF(ML[MSelectGR[0]].alf.Q, MSelectGR.Count - 1);
            }
            Round();
        }
Esempio n. 10
0
        private TabPage TapPageCreate()
        {
            CorelDataGridView                               = new DataGridView();
            CorelDataGridView.Location                      = new Point(0, 0);
            CorelDataGridView.Dock                          = DockStyle.Fill;
            CorelDataGridView.AllowUserToAddRows            = false;
            CorelDataGridView.ColumnHeaderMouseDoubleClick +=
                new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.CorelatioDataGridView_ColumnHeaderMouseDoubleClick);
            CorelDataGridView.TopLeftHeaderCell.Value
                = Math.Round(Distributions.StudentQuantile(1 - IAM.ISA[0].alf.Q / 2, IAM.N - 2), 4).ToString();
            CorelDataGridView.RowHeadersWidth = 60;

            //
            // BottomValueToolStripMenuItem
            //
            this.BottomValueToolStripMenuItem        = new System.Windows.Forms.ToolStripMenuItem();
            this.BottomValueToolStripMenuItem.Name   = "BottomValueToolStripMenuItem";
            this.BottomValueToolStripMenuItem.Size   = new System.Drawing.Size(223, 22);
            this.BottomValueToolStripMenuItem.Text   = "Нижній довірчий інтервал";
            this.BottomValueToolStripMenuItem.Click += new System.EventHandler(this.BottomValueToolStripMenuItem_Click);
            //
            // UppperValueToolStripMenuItem
            //
            this.UppperValueToolStripMenuItem        = new System.Windows.Forms.ToolStripMenuItem();
            this.UppperValueToolStripMenuItem.Name   = "UppperValueToolStripMenuItem";
            this.UppperValueToolStripMenuItem.Size   = new System.Drawing.Size(223, 22);
            this.UppperValueToolStripMenuItem.Text   = "Верхній довірчий інтервал";
            this.UppperValueToolStripMenuItem.Click += new System.EventHandler(this.UppperValueToolStripMenuItem_Click);
            //
            // ValueToolStripMenuItem
            //
            this.ValueToolStripMenuItem        = new System.Windows.Forms.ToolStripMenuItem();
            this.ValueToolStripMenuItem.Name   = "ValueToolStripMenuItem";
            this.ValueToolStripMenuItem.Size   = new System.Drawing.Size(223, 22);
            this.ValueToolStripMenuItem.Text   = "Оцінка кореляції";
            this.ValueToolStripMenuItem.Click += new System.EventHandler(this.ValueToolStripMenuItem_Click);
            //
            // TToolStripMenuItem
            //
            this.TToolStripMenuItem        = new System.Windows.Forms.ToolStripMenuItem();
            this.TToolStripMenuItem.Name   = "TToolStripMenuItem";
            this.TToolStripMenuItem.Size   = new System.Drawing.Size(223, 22);
            this.TToolStripMenuItem.Text   = "t ";
            this.TToolStripMenuItem.Click += new System.EventHandler(this.TToolStripMenuItem_Click);
            //
            // HToolStripMenuItem
            //
            this.HToolStripMenuItem        = new System.Windows.Forms.ToolStripMenuItem();
            this.HToolStripMenuItem.Name   = "HToolStripMenuItem";
            this.HToolStripMenuItem.Size   = new System.Drawing.Size(223, 22);
            this.HToolStripMenuItem.Text   = "Значущість (= 0)";
            this.HToolStripMenuItem.Click += new System.EventHandler(this.HToolStripMenuItem_Click);
            //
            // CorelContextMenuStrip
            //
            CorelContextMenuStrip = new ContextMenuStrip();
            CorelDataGridView.ContextMenuStrip = CorelContextMenuStrip;
            this.CorelContextMenuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
                this.UppperValueToolStripMenuItem,
                this.ValueToolStripMenuItem,
                this.BottomValueToolStripMenuItem,
                this.TToolStripMenuItem,
                this.HToolStripMenuItem
            });
            this.CorelContextMenuStrip.Name = "contextMenuStrip1";
            this.CorelContextMenuStrip.Size = new System.Drawing.Size(224, 158);


            System.Windows.Forms.TabPage tabPagenew = new TabPage();
            tabPagenew.Controls.Add(CorelDataGridView);
            tabPagenew.Location = new System.Drawing.Point(4, 22);
            tabPagenew.Name     = "tabPage3";
            tabPagenew.Padding  = new System.Windows.Forms.Padding(3);
            tabPagenew.Size     = new System.Drawing.Size(1005, 273);
            tabPagenew.TabIndex = 0;
            tabPagenew.Text     = "Кореляція";
            tabPagenew.UseVisualStyleBackColor = true;
            tabPagenew.ResumeLayout(false);
            return(tabPagenew);
        }