Ejemplo n.º 1
0
        public static Result TestSpearmanMethod(List <double> excerpt)
        {
            double[,] h = new double[excerpt.Count - 1, excerpt.Count - 1];
            for (int i = 0; i < excerpt.Count - 1; i++)
            {
                for (int j = i + 1; j < excerpt.Count; j++)
                {
                    if (excerpt[i] == excerpt[j])
                    {
                        h[i, j - 1] = 0.5;
                    }
                    else if (excerpt[i] < excerpt[j])
                    {
                        h[i, j - 1] = 1;
                    }
                }
            }
            double v = 0;

            for (int i = 0; i < excerpt.Count - 1; i++)
            {
                for (int j = i + 1; j < excerpt.Count; j++)
                {
                    v += (j - 1) * h[i, j - 1];
                }
            }
            double rc = 1 - 12 * v / excerpt.Count / (excerpt.Count * excerpt.Count - 1);
            double d  = 1.0 / (excerpt.Count - 1);
            double s  = rc / Math.Sqrt(d);
            double q  = DistributionHelper.GetNormalDistributionQuantile(TimeSeriesEnvironment.Current.Alpha);

            return(new Result(q, s));
        }
Ejemplo n.º 2
0
        public static StatEstimationResult StatEstimation(Queue q, int m)
        {
            int           n     = q.Count;
            List <double> times = q.ToTime;
            double        dt    = times.Last() / m;

            List <StatEstimationClassResult> intervals = new List <StatEstimationClassResult>();
            double ua           = DistributionHelper.GetNormalDistributionQuantile(Globals.Alpha / 2);
            double constantPart = ua * ua / n / dt / 2;

            for (int i = 0; i < m; i++)
            {
                int                ns      = times.Count(x => x >= dt * i && (i == m - 1 || x < dt * (i + 1)));
                double             us      = ns / dt / n;
                double             difPart = ua * Math.Sqrt(ns + ua * ua / 4) / n / dt;
                ConfidenceInterval cnf     = new ConfidenceInterval(us, x => x + constantPart - difPart, x => x + constantPart + difPart, dt * i, dt * (i + 1));
                intervals.Add(new StatEstimationClassResult(i + 1, cnf));
            }

            return(new StatEstimationResult(intervals));
        }
Ejemplo n.º 3
0
        public static Result TestSignsMethod(List <double> excerpt)
        {
            double l = 0,
                   m = (excerpt.Count - 1) / 2,
                   d = (excerpt.Count + 1) / 12;

            for (int i = 0; i < excerpt.Count - 1; i++)
            {
                if (excerpt[i] == excerpt[i + 1])
                {
                    l += 0.5;
                }
                else if (excerpt[i] > excerpt[i + 1])
                {
                    l += 1;
                }
            }
            double u = (l - m) / Math.Sqrt(d);
            double q = DistributionHelper.GetNormalDistributionQuantile(TimeSeriesEnvironment.Current.Alpha);

            return(new Result(q, u));
        }