예제 #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);
        }
예제 #2
0
        public static double rangeGetGroup(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("子组容量过大");
            }
            double range = 0;
            int    s     = start;

            for (int i = 0; i < a; i++)
            {
                int    j   = s;
                double max = double.NegativeInfinity;
                double min = double.PositiveInfinity;
                for (int c = 0; c < grouplength; j++)
                {
                    double?temp = data[j];
                    if (temp != null)
                    {
                        double dtemp = (double)temp;
                        if (dtemp > max)
                        {
                            max = dtemp;
                        }
                        if (dtemp < min)
                        {
                            min = dtemp;
                        }
                        c++;
                    }
                }
                range += (max - min) / a;
                s      = j;
            }
            range = range / StandardConst.D2[(int)grouplength];
            return(range);
        }
예제 #3
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);
        }
예제 #4
0
        public static double GetAvgMovingRangeXBar(ICanGetProperty data, int start, int count)
        {
            int    s = start;
            double?pre;
            double rbar = 0;

            while ((pre = data[s++]) == null)
            {
                ;
            }
            for (int i = s, c = 1; c < count; i++)
            {
                double?temp = data[i];
                if (temp != null)
                {
                    rbar += Math.Abs((double)(temp - pre));
                    c++;
                    pre = temp;
                }
            }
            rbar = rbar / (count - 1);
            return(rbar / StandardConst.D2[2]);
        }
예제 #5
0
        public static double GetEntirety(ICanGetProperty data, double avg, int start, int count)
        {
            double sum = 0;

            if (count < 1)
            {
                throw new Exception("GetEntirety无数据");
            }
            for (int i = start, c = 0; c < count; i++)
            {
                double?temp = data[i];
                if (temp != null)
                {
                    sum += Math.Pow((double)temp - avg, 2);
                    c++;
                }
            }
            if (count == 1)
            {
                count++;
            }
            return(Math.Pow(sum / (count - 1), 0.5));
        }
예제 #6
0
 public static double GetGroup(ICanGetProperty data, double avg, int start, int count, int grouplength, STDEVType type)
 {
     return(type.Get(data, avg, start, count, grouplength));
 }