Exemple #1
0
        double SimpleMx(InitialStatisticalAnalys gr1, InitialStatisticalAnalys gr2)
        {
            if (gr1.l.Count != gr2.l.Count)
            {
                if (gr1.l.Count + gr2.l.Count <= 25)
                {
                    double A = gr1.Mx.Q - gr2.Mx.Q;
                    double B = Math.Sqrt((gr1.l.Count * gr2.l.Count) / (gr1.l.Count + gr2.l.Count));
                    double C = (gr1.l.Count - 1) * gr1.Dx.Q + (gr2.l.Count - 1) * gr2.Dx.Q;
                    C /= gr1.l.Count + gr2.l.Count - 2;
                    C  = Math.Sqrt(C);
                    return(A * B / C);
                }
                return((gr1.Mx.Q - gr2.Mx.Q) / Math.Sqrt((gr1.Dx.Q / gr1.l.Count) + (gr2.Dx.Q / gr2.l.Count)));
            }
            for (int i = 0; i < gr1.l.Count; i++)
            {
                Z.Add(gr1.unsortl[i] - gr2.unsortl[i]);
            }
            InitialStatisticalAnalys TG = new InitialStatisticalAnalys(Z);

            if (TG.Mx.Q == TG.Gx.Q && TG.Mx.Q == 0)
            {
                return(0);
            }
            return(TG.Mx.Q * Math.Sqrt(TG.l.Count) / TG.Gx.Q);
        }
        static public string TypeRegresFound(InitialStatisticalAnalys ISAX, InitialStatisticalAnalys ISAY)
        {
            string[] Type    = Regex.Split(RegresTypeName.TypeRegresion, "\n");
            double[] Szalmas = new double[Type.Length];
            double   Korel   = KorelationFound(ISAX, ISAY);

            for (int i = 0; i < Type.Length; i++)
            {
                double      td = 0;
                List <Data> q  = RegresParamFound(ISAX, ISAY, Korel, Type[i], ref td);
                Szalmas[i] = SzalF(ISAX, ISAY, q, Type[i]);
            }
            double min   = Szalmas[0];
            int    index = 0;

            for (int i = 0; i < Type.Length; i++)
            {
                if (min != double.NaN && Szalmas[i] <= min)
                {
                    min   = Szalmas[i];
                    index = i;
                }
            }
            return(Type[index]);
        }
        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));
        }
Exemple #4
0
#pragma warning disable IDE1006
        double[,] fFound(InitialStatisticalAnalys gr1, InitialStatisticalAnalys gr2, int Ncol, int Nrow)
#pragma warning restore IDE1006
        {
            double[,] rez = new double[Ncol, Nrow];
            for (int i = 0; i < gr1.l.Count; i++)
            {
                for (int j = 0; j < Ncol; j++)
                {
                    for (int k = 0; k < Nrow; k++)
                    {
                        if (gr1.unsortl[i] <= (j + 1) * gr1.Len.Q / Ncol + gr1.Min.Q && gr1.unsortl[i] >= (j * gr1.Len.Q / Ncol + gr1.Min.Q) &&
                            gr2.unsortl[i] <= ((k + 1) * gr2.Len.Q / Nrow + gr2.Min.Q) && gr2.unsortl[i] >= (k * gr2.Len.Q / Nrow + gr2.Min.Q))
                        {
                            rez[j, k] += 1.0 / gr1.l.Count;
                            goto t1;
                        }
                    }
                }
                t1 :;
            }

            /*for (int j = 0; j < Ncol; j++)
             *  for (int k = 0; k < Nrow; k++)
             *      if (rez[j, k] <= gr1.alf)
             *          rez[j, k] = 0;*/
            return(rez);
        }
#pragma warning disable IDE1006
        static public double[] fi1F(InitialStatisticalAnalys ISA)
        {
            double[] rez = new double[ISA.unsortl.Length]; ///page 108
            for (int i = 0; i < rez.Length; i++)
            {
                rez[i] = ISA.unsortl[i] - ISA.Mx.Q;
            }
            return(rez);
            //return element - mx;
        }
Exemple #6
0
 double SimpleS(InitialStatisticalAnalys gr1, InitialStatisticalAnalys gr2)
 {
     if (gr1.Dx.Q >= gr2.Dx.Q)
     {
         return(gr1.Dx.Q / gr2.Dx.Q);
     }
     else
     {
         return(gr2.Dx.Q / gr1.Dx.Q);
     }
 }
        static public double SzalF(InitialStatisticalAnalys ISAX, InitialStatisticalAnalys ISAY, List <Data> Q, string RegresTypeN)
        {
            double Szal = 0;

            for (int i = 0; i < ISAX.unsortl.Length; i++)
            {
                Szal += Math.Pow(ISAY.unsortl[i] - RegresType.Model(ISAX.unsortl[i], Q, RegresTypeN), 2);
            }
            Szal /= (ISAX.unsortl.Length - Q.Count);
            return(Math.Sqrt(Szal));
        }
Exemple #8
0
        private double SzalFound(double[] AB, InitialStatisticalAnalys X, InitialStatisticalAnalys Y)
        {
            double rez = 0;

            for (int i = 0; i < Y.l.Count; i++)
            {
                rez += Math.Abs(Y.unsortl[i] - AB[0] - AB[1] * X.unsortl[i]);
            }
            rez /= X.l.Count;
            return(rez);
        }
        static public double[] fi2F(InitialStatisticalAnalys ISA)
        {
            double[] rez = new double[ISA.unsortl.Length]; ///page 108
            double   x3  = InitialStatisticalAnalys.StartMoment(ISA.l, 3);
            double   x2  = InitialStatisticalAnalys.StartMoment(ISA.l, 2);

            for (int i = 0; i < rez.Length; i++)
            {
                rez[i] = Math.Pow(ISA.unsortl[i], 2) - (x3 - x2 * ISA.Mx.Q) * (ISA.unsortl[i] - ISA.Mx.Q) / ISA.Dx.Q - x2;
            }
            return(rez);
        }
Exemple #10
0
        double KrsumRangVilsFound(double[,] rang, InitialStatisticalAnalys gr1, InitialStatisticalAnalys gr2)
        {
            double KrsumRangVils = 0, Mw = 0, Dw = 0;

            for (int i = 0; i < N; i++)
            {
                if (rang[i, 1] == 0)
                {
                    KrsumRangVils += rang[i, 0];
                }
            }
            Mw = gr1.l.Count * (N + 1) / 2;
            Dw = gr1.l.Count * gr2.l.Count * (N + 1) / 12;
            return((KrsumRangVils - Mw) / Math.Sqrt(Dw));
        }
        public static double KorelationFound(InitialStatisticalAnalys ISAX, InitialStatisticalAnalys ISAY)
        {
            double Mxy = 0;
            double sx = 0, sy = 0;

            for (int i = 0; i < ISAX.l.Count; i++)
            {
                sx  += ISAX.unsortl[i];
                sy  += ISAY.unsortl[i];
                Mxy += ISAX.unsortl[i] * ISAY.unsortl[i];
            }
            var ty = Mxy / Math.Sqrt(sx * sy);

            Mxy /= ISAX.l.Count;

            return((ISAX.l.Count / (ISAX.l.Count - 1)) *
                   ((Mxy - ISAX.Mx.Q * ISAY.Mx.Q) / (ISAX.Gx.Q * ISAY.Gx.Q)));
        }
Exemple #12
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);
        }
Exemple #13
0
        double RizSerRangVibFound(double[,] rang, InitialStatisticalAnalys gr1, InitialStatisticalAnalys gr2)
        {
            double Mrx = 0, Mry = 0;

            for (int i = 0; i < N; i++)
            {
                if (rang[i, 1] == 0)
                {
                    Mrx += rang[i, 0];
                }
                else if (rang[i, 1] == 1)
                {
                    Mry += rang[i, 0];
                }
            }
            Mrx /= gr1.l.Count;
            Mry /= gr2.l.Count;
            double v = (Mrx - Mry) / (N * Math.Sqrt((N + 1) / (12.0 * gr1.l.Count * gr2.l.Count)));

            return(v);
        }
Exemple #14
0
        private void ABTailFound(InitialStatisticalAnalys gr1, InitialStatisticalAnalys gr2)
        {
            double        B = 0;
            double        A = 0;
            List <double> b = new List <double>();

            for (int i = 1; i < gr1.l.Count; i++)
            {
                for (int j = 0; j < i; j++)
                {
                    b.Add((gr2.unsortl[j] - gr2.unsortl[i]) / (gr1.unsortl[j] - gr1.unsortl[i]));
                }
            }
            b.Sort();
            if (b.Count % 2 == 0)
            {
                B = (b[b.Count / 2 - 1] + b[b.Count / 2]) / 2;
            }
            else
            {
                B = b[(b.Count - 1) / 2];
            }
            List <double> a = new List <double>();

            for (int i = 0; i < gr1.l.Count; i++)
            {
                a.Add(gr2.unsortl[i] - B * gr1.unsortl[i]);
            }
            a.Sort();
            if (a.Count % 2 == 0)
            {
                A = (a[a.Count / 2 - 1] + a[a.Count / 2]) / 2;
            }
            else
            {
                A = a[(a.Count - 1) / 2];
            }
            ABTeil[0] = A;
            ABTeil[1] = B;
        }
Exemple #15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="ML"></param>
        /// <param name="gr"></param>
        /// <param name="type"></param>
        /// <returns>P</returns>
        static public double KolmagorovFound(List <double> ML, InitialStatisticalAnalys gr, int type, double Mx, double Gx)
        {
            double D   = DFound(ML, gr, type, Mx, Gx);
            double Z   = Math.Sqrt(ML.Count) * D;
            double rez = 0;
            double A1  = (double)1 / (18 * ML.Count);

            for (int k = 1; k < 75; k++)
            {
                double f1 = k * k - 0.5 * (1 - Math.Pow(-1, k));
                double f2 = 5 * k * k + 22 - 7.5 * (1 - Math.Pow(-1, k));
                //double O = Math.Pow(Z, 13) / Math.Pow(ML.Count,2);
                double C1 = (f1 - 4 * (f1 + 3)) * Math.Pow(Z * k, 2) + 8 * Math.Pow(k * Z, 4);
                double C2 = (f2 * f2 / 5 - 4 * (f2 + 45) * Math.Pow(Z * k, 2) / (15) + 8 * Math.Pow(k * Z, 4));
                double B1 = 1 - 2 * k * k * Z / (3 * Math.Sqrt(ML.Count));
                double A2 = k * k * Z / (27 * Math.Pow(ML.Count, 1.5));
                double G  = Math.Pow(-1, k) * Math.Exp((double)-2 * Math.Pow(k * Z, 2));
                rez += G * (B1 - A1 * C1 + A2 * C2);
            }
            rez *= 2;
            return(-rez);
        }
Exemple #16
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]));
 }
Exemple #17
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);
        }
Exemple #18
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);
            }
        }
Exemple #19
0
        double KrUMannaUitFound(InitialStatisticalAnalys gr1, InitialStatisticalAnalys gr2)
        {
            double u = 0, Mu = 0, Du = 0;

            double[,] z = new double[gr1.l.Count, gr2.l.Count];
            for (int i = 0; i < gr1.l.Count; i++)
            {
                for (int j = 0; j < gr2.l.Count; j++)
                {
                    if (gr1.unsortl[i] > gr2.unsortl[j])
                    {
                        z[i, j] = 1;
                        u++;
                    }
                    else
                    {
                        z[i, j] = 0;
                    }
                }
            }
            Mu = gr1.l.Count * gr2.l.Count / 2;
            Du = Mu * (N + 1) / 6;
            return((u - Mu) / Math.Sqrt(Du));
        }
Exemple #20
0
 double cov(InitialStatisticalAnalys ISAe1, InitialStatisticalAnalys ISAe2)
 {
     return(ISAe1.Gx.Q * ISAe2.Gx.Q * Correlation_RegressionAnalysis.KorelationFound(ISAe1, ISAe2));
 }
Exemple #21
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="ML"></param>
 /// <param name="gr"></param>
 /// <param name="type"></param>
 /// <returns>P</returns>
 static public double KolmagorovFound(List <double> ML, InitialStatisticalAnalys gr, int type)
 {
     return(KolmagorovFound(ML, gr, type, gr.Mx.Q, gr.Gx.Q));
 }
        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);
        }
Exemple #23
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);
        }