Example #1
0
        public static double nstdGetGroup(ICanGetProperty data, double avg, int start, int count, int grouplength)
        {
            int a = (int)(count / grouplength);

            if (a < 1)
            {
                throw new Exception("子组容量过大");
            }
            if (grouplength < 1)
            {
                throw new Exception("子组大小必须大于0");
            }
            double std = 0;
            int    s   = start;

            for (int i = 0; i < a; i++)
            {
                double gavg = 0;
                int    j    = s;
                for (int c = 0; c < grouplength; j++)
                {
                    double?temp = data[j];
                    if (temp != null)
                    {
                        gavg += (double)temp / grouplength;
                        c++;
                    }
                }
                std += STDEV.GetEntirety(data, gavg, s, grouplength) / a;
                s    = j;
            }
            return(std);
        }
Example #2
0
        public static double stdGetGroup(ICanGetProperty data, double avg, int start, int count, int grouplength)
        {
            int a = (int)(count / grouplength);

            if (a < 1)
            {
                throw new Exception("子组容量过大");
            }
            if (grouplength < 1)
            {
                throw new Exception("子组大小必须大于0");
            }
            if (grouplength >= StandardConst.D2.Length || grouplength > count)
            {
                throw new Exception("子组容量过大");
            }
            ArrayVector std    = new ArrayVector(a);
            int         s      = start;
            double      result = 0;
            ArrayVector gavg   = new ArrayVector(a);

            for (int i = 0; i < a; i++)
            {
                int j = s;
                for (int c = 0; c < grouplength; j++)
                {
                    double?temp = data[j];
                    if (temp != null)
                    {
                        gavg.Data[i] += (double)temp / grouplength;
                        c++;
                    }
                }
                gavg.AVG   += gavg.Data[i] / a;
                std.Data[i] = STDEV.GetEntirety(data, gavg.Data[i], s, grouplength);
                std.AVG    += std.Data[i] / a;
                s           = j;
            }
            std.AVG = std.AVG / StandardConst.C4[(int)grouplength];
            //double rbar = (std.data[1] - std.data[0]) / StandardConst.D2[2];
            //double rbar = GetAvgMovingRangeXBar(data, start, count);
            //bgstd =Math.Max(0, Math.Pow(Math.Pow(rbar,2) - Math.Pow(std.AVG,2)/a,0.5));
            //result = Math.Pow(Math.Pow(bgstd, 2) + Math.Pow(std.AVG, 2), 0.5);
            result = std.AVG;
            return(result);
        }