コード例 #1
0
        static public double HiSqurdFound(InitialStatisticalAnalys gr, int l)
        {
            double        Hi = 0;
            List <double> Y4 = new List <double>();
            double        L  = (double)1 / gr.Mx.Q;

            for (double i = gr.l[0], v = 0; v < gr.Y2.Count; i += gr.Step.Q, v++)
            {
                if (l == 0)
                {
                    Y4.Add(Distributions.NormalFFound(((i + gr.Step.Q) - gr.Mx.Q) / gr.Gx.Q) - Distributions.NormalFFound((i - gr.Mx.Q) / gr.Gx.Q));
                }
                else if (l == 1)
                {
                    double F2 = 1 - Math.Exp(-(1 / gr.Mx.Q) * (gr.Min.Q + gr.Step.Q * (v + 1)));
                    double F1 = 1 - Math.Exp(-(1 / gr.Mx.Q) * (gr.Min.Q + gr.Step.Q * (v)));
                    Y4.Add(F2 - F1);
                }
                else if (l == 2)
                {
                    Y4.Add(gr.Step.Q / gr.Len.Q);
                }
            }
            for (int i = 0; i < gr.m.Q; i++)
            {
                Hi += (Math.Pow(Y4[i] - gr.f[i], 2) / Y4[i]) * gr.l.Count;
            }
            return(Math.Round(Hi, 4));
        }
コード例 #2
0
        private double[] TypeRFound()
        {
            double[] TypeR = new double[3];
            double   i2    = -0.5;

            for (int i = 0; i < l.Count - 1; i++, i2 += (double)1 / l.Count)
            {
                double v1  = Distributions.NormalFobrFound(i2);
                double Y_X = ((this.l[i] - Min.Q) / Len.Q);
                //double l = Math.Abs((ML[i] - ML[0]) / ((ML[ML.Count - 1] - ML[0])) - ((v1 * gr.Gx + gr.Mx.Q - ML[0]) / (ML[ML.Count - 1] - ML[0])));
                double li = Math.Abs((l[i] - v1 * Gx.Q - Mx.Q) / Len.Q);
                TypeR[0] += Math.Pow(li, 2);
                TypeR[1] += Math.Pow((this.F[i]) - (1 - Math.Pow(2.73, -(1 / this.Mx.Q) * (this.l[i] - this.Min.Q))), 2);
                TypeR[2] += Math.Pow((this.F[i]) - Y_X, 2);
            }
            TypeR[0] /= (this.l.Count - 1);
            TypeR[1] /= (this.l.Count - 1);
            TypeR[2] /= (this.l.Count - 1);
            if (TypeR[0] < TypeR[1] && TypeR[0] < TypeR[2])
            {
                AvtoType = "Нормальний";
            }
            else if (TypeR[1] < TypeR[0] && TypeR[1] < TypeR[2])
            {
                AvtoType = "Експоненціальний";
            }
            else if (TypeR[2] < TypeR[1] && TypeR[2] < TypeR[0])
            {
                AvtoType = "Рівномірний";
            }
            return(TypeR);
        }
        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);
        }
コード例 #4
0
        static public double StudentQuantile(double alf, int m)
        {
            double T     = 0;
            double u_alf = Math.Abs(Distributions.NormalQuantile(alf /*1 - 0.05 / 2*/));
            double g1    = (Math.Pow(u_alf, 3) + u_alf) / 4;
            double g2    = (5 * Math.Pow(u_alf, 5) + 16 * Math.Pow(u_alf, 3) + 3 * u_alf) / 96;
            double g3    = (34 * Math.Pow(u_alf, 7) + 19 * Math.Pow(u_alf, 5) + 17 * Math.Pow(u_alf, 3) - 15 * u_alf) / 384;
            double g4    = (79 * Math.Pow(u_alf, 9) + 779 * Math.Pow(u_alf, 7) + 1482 * Math.Pow(u_alf, 5) - 1920 * Math.Pow(u_alf, 3) - 945 * u_alf) / 92160;

            T = u_alf + g1 / (m) + g2 / Math.Pow(m, 2) + g3 / Math.Pow(m, 3) + g4 / Math.Pow(m, 4);
            return(T);
        }
コード例 #5
0
        private void DataSet(List <InitialStatisticalAnalys> ISA, List <int> IND, int k)
        {
            this.k   = k;
            this.ISA = new List <InitialStatisticalAnalys>();
            Ex       = new double[IND.Count];
            for (int i = 0; i < IND.Count; i++)
            {
                this.ISA.Add(ISA[IND[i]]);
                Ex[i] = ISA[IND[i]].Mx.Q;
            }
            n       = this.ISA.Count;
            N       = this.ISA[0].unsortl.Length;
            DC      = DCFound(ISA, IND);
            K       = KFound(ISA, IND);
            X       = XFound(this.ISA, n, N, k);
            KTurnOn = new bool[n];
            for (int i = 0; i < KTurnOn.Length; i++)
            {
                KTurnOn[i] = true;
            }
            if (k >= 0)
            {
                Y   = YFound(this.ISA, n, N, k);
                CMC = new Data[n];
                for (int i = 0; i < n; i++)
                {
                    CMC[i]        = new Data();
                    CMC[i].Name   = "Коеф. багатов. корел.";
                    CMC[i].Q      = CMCFound(ISA, K, i);
                    CMC[i].QKvant = (N - n - 1) * (Math.Pow(CMC[i].Q, 2)) / (n * (1 - Math.Pow(CMC[i].Q, 2)));
                    CMC[i].Q0     = Distributions.FisherQuantile(1 - ISA[0].alf.Q / 2, n, N - n - 1);
                }

                SigmKv = Math.Sqrt(this.ISA[k].Dx.Q * (1 - Math.Pow(CMC[k].Q, 2)) * (N - 1) / (N - n - 1));

                CoefDeter      = new Data();
                CoefDeter.Name = "Коефіціент Детермінації = ";
                CoefDeter.Q    = Math.Pow(CMC[k].Q, 2);


                ZnachRegres        = new Data();
                ZnachRegres.Name   = "Перевірка значущості від. регресії";
                ZnachRegres.QKvant = (N - n) * ((1 / (1 - CoefDeter.Q)) - 1) / (n - 1);
                ZnachRegres.Q0     = Distributions.FisherQuantile(1 - ISA[0].alf.Q / 2, n - 1, N - n - 2);

                C         = CFound(n, X);
                A         = MuliplRegresFound(this.ISA, k);
                Astandart = AstndF(this.ISA, A, k);
                Szal      = SzalFound(this.ISA, k, A);
            }
        }
コード例 #6
0
        private double X2fFound(InitialStatisticalAnalys gr1, InitialStatisticalAnalys gr2, double[,] f)
        {
            double rez = 0;

            for (int i = 0; i < f.GetLength(0); i++)
            {
                for (int j = 0; j < f.GetLength(1); j++)
                {
                    double f1 = Distributions.NormalDoublefFound(
                        ((i + 0.5) * gr1.Len.Q / f.GetLength(0) + gr1.Min.Q), gr1.Mx.Q, gr1.Gx.Q,
                        ((j + 0.5) * gr2.Len.Q / f.GetLength(1) + gr2.Min.Q), gr2.Mx.Q, gr2.Gx.Q, Korelation[0]) *
                                (gr2.Len.Q / f.GetLength(1)) * (gr1.Len.Q / f.GetLength(0));
                    if (Math.Round(f1, 4) != 0)
                    {
                        rez += Math.Pow(f[i, j] - f1, 2) / f1;
                    }
                }
            }
            return(rez);
        }
コード例 #7
0
        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();
        }
コード例 #8
0
 static private double DFound(List <double> ML, InitialStatisticalAnalys gr, int Type, double Mx, double Gx)
 {
     double[] D = new double[2];
     for (int i = 0; i < gr.l.Count - 1; i++)
     {
         double l    = 0;
         double lmin = 0;
         if (Type == 0)
         {
             double v1 = Distributions.NormalFFound((gr.l[i] - Mx) / Gx);
             l = Math.Abs(gr.F[i] - v1);
             if (i > 0)
             {
                 v1   = Distributions.NormalFFound((gr.l[i - 1] - Mx) / Gx);
                 lmin = Math.Abs(gr.F[i] - v1);
             }
         }
         else if (Type == 1)
         {
             l = Math.Abs(gr.F[i] - 1 + Math.Pow(2.73, -(1 / (Mx - gr.Min.Q)) * (gr.l[i] - gr.Min.Q)));
             if (i > 0)
             {
                 lmin = Math.Abs(gr.F[i] - 1 + Math.Pow(2.73, -(1 / (Mx - gr.Min.Q)) * (gr.l[i - 1] - gr.l[0])));
             }
         }
         else if (Type == 2)
         {
             l = Math.Abs(gr.F[i] - ((gr.l[i] - gr.l[0]) / gr.Len.Q));
             if (i > 0)
             {
                 lmin = Math.Abs(gr.F[i] - ((gr.l[i - 1] - ML[0]) / gr.Len.Q));
             }
         }
         D[1] = Math.Max(l, D[1]);
         D[0] = Math.Max(lmin, D[0]);
     }
     return(Math.Max(D[0], D[1]));
 }
コード例 #9
0
        double KrZnakivFound(InitialStatisticalAnalys gr1, InitialStatisticalAnalys gr2)
        {
            double        S  = 0;
            double        hN = gr1.l.Count;
            List <double> Z  = new List <double>();

            for (int i = 0; i < gr1.l.Count && i < gr2.l.Count; i++)
            {
                Z.Add(gr1.unsortl[i] - gr2.unsortl[i]);
                if (gr1.unsortl[i] - gr2.unsortl[i] > 0)
                {
                    S++;
                }
                if (gr1.unsortl[i] - gr2.unsortl[i] == 0)
                {
                    hN--;
                }
            }
            if (hN <= 15)
            {
                double alf0 = 0;
                for (int i = 0; i <= hN - S; i++)
                {
                    alf0 += CFound(i, hN);
                }
                alf0       *= Math.Pow(2, -hN);
                KrZnakiv[1] = gr1.alf.Q;
                return(alf0);
            }
            else
            {
                double Sn = (S - 0.5 - hN / 2) / Math.Sqrt(hN / 4);
                KrZnakiv[1] = Distributions.NormalQuantile(1 - gr1.alf.Q / 2);
                return(Sn);
            }
        }
コード例 #10
0
        private double ZFound(InitialStatisticalAnalys gr1, InitialStatisticalAnalys gr2)
        {
            double D = 0;

            for (int i = 0; i < gr1.l.Count; i++)
            {
                double l2 = 0;
                if (gr2.AvtoType == "Нормальний")
                {
                    l2 = Distributions.NormalfFound(gr1.l[i], gr2.Mx.Q, gr2.Gx.Q);
                }
                else if (gr2.AvtoType == "Еспоненціальний")
                {
                    l2 = Distributions.ExpFound(gr1.l[i], gr2.Mx.Q);
                }
                else if (gr2.AvtoType == "Рівномірний")
                {
                    l2 = (gr1.l[i] - gr2.Min.Q) * gr2.Len.Q;
                }

                D = Math.Max(Math.Abs(gr1.F[i] - l2), D);
            }
            return(D);
        }
コード例 #11
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();
        }
コード例 #12
0
        private bool NachYslovRegAnal(InitialStatisticalAnalys gr1, InitialStatisticalAnalys gr2)
        {
            AB[1] = Korelation[0] * gr2.Gx.Q / gr1.Gx.Q;
            AB[0] = gr2.Mx.Q - AB[1] * gr1.Mx.Q;
            bool rez = true;

            if (!(gr1.AvtoType == gr2.AvtoType && gr2.AvtoType == "Нормальний"))
            {
                rez = false;
            }
            int M = 18;

            List <double>[] yi = new List <double> [M];
            for (int i = 0; i < M; i++)
            {
                yi[i] = new List <double>();
            }
            for (int i = 0; i < ML[MSelectGR[0]].l.Count; i++)
            {
                for (int j = 0; j < M; j++)
                {
                    if (gr1.unsortl[i] < (j + 1.0001) * gr1.Len.Q / M + gr1.Min.Q && gr1.unsortl[i] >= (j * gr1.Len.Q / M + gr1.Min.Q))
                    {
                        yi[j].Add(gr2.unsortl[i]);
                        break;
                    }
                }
            }
            ///ProvRegr
            double t1 = 0, t2 = 0;

            ///


            double[] Sxj = new double[M];
            double   S   = 0;

            for (int i = 0; i < M; i++)
            {
                double ysr = yi[i].Sum() / yi[i].Count;
                if (ysr > 0)
                {
                    for (int j = 0; j < yi[i].Count; j++)
                    {
                        t2     += Math.Pow(yi[i][j] - ysr, 2);
                        Sxj[i] += Math.Pow(yi[i][j] - ysr, 2);
                    }
                    if (yi[i].Count > 1)
                    {
                        Sxj[i] /= yi[i].Count - 1;
                    }
                    t1 += yi[i].Count * Math.Pow(ysr - AB[0] - AB[1] * ((i + 0.5) * gr1.Len.Q / M + gr1.Min.Q), 2);
                }
            }
            ProvRegrs[0] = (gr1.l.Count - M) * t1 / ((M - 1) * t2);
            ProvRegrs[1] = Distributions.FisherQuantile(gr1.alf.Q, M - 1, gr1.l.Count - M);

            double C = 0;

            for (int i = 0; i < M; i++)
            {
                S += (yi[i].Count - 1) * Sxj[i];
                if (yi[i].Count != 0)
                {
                    C += 1.0 / yi[i].Count - 1.0 / gr1.l.Count;
                }
            }
            S /= gr1.l.Count - M;
            //C -= 1 / gr1.l.Count;
            C /= 3.0 * (M - 1);
            C++;
            for (int i = 0; i < M; i++)
            {
                if (Sxj[i] != 0)
                {
                    KriterBarkleta[0] += yi[i].Count * Math.Log(Sxj[i] / S);
                }
            }
            KriterBarkleta[0] /= -C;
            KriterBarkleta[1]  = Hi.HIF(gr1.alf.Q, M - 1);



            return(rez);
        }
コード例 #13
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();
        }
        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);
        }