Ejemplo n.º 1
0
        static public Model ModelQuick(TimeSeries ts)
        {
            Model m = new Model();

            m.ts       = ts;
            m.seasonal = null;
            m.values   = null;
            m.errors   = null;

            m.type = ModelType.Explicit;
            m.Solve();
            m.CalcError();
            // m.ComputeErrorRange();
            m.error = m.Error(Global.confidence);
            m.len   = ts.Length;
            return(m);
        }
Ejemplo n.º 2
0
        public void Solve()
        {
            if (type == ModelType.PLA)
            {
                values = new double[2];
                double asum = 0;
                double bsum = 0;

                for (int i = 0; i < this.ts.Length; i++)
                {
                    asum += ((i + 1) - ((ts.Length + 1) / 2)) * ts.data[i];
                    bsum += ((i + 1) - ((2 * ts.Length + 1) / 3)) * ts.data[i];
                }
                values[0] = 12 * asum / ts.Length / (ts.Length + 1) / (ts.Length - 1);
                values[1] = 6 * bsum / ts.Length / (1 - ts.Length);
                return;
            }

            int n = ts.Length;
            int l = 0;
            freq = ts.freq[0];
            while (freq > ts.Length)
            {
                if (l == ts.freq.Length)
                {
                    return;
                }
                freq = ts.freq[l++];

            }

            if (freq == 0)
            {
                //use regression
                values = ChebyshevReg.Solve(ts.data);
                seasonal = null;
            }
            else
            {
                double[] season_ = new double[freq];
                decompose(n, freq, season_);
                seasonal = new Model();
                int[] f;
                if (ts.freq.Length == 1) f = null;
                else
                {
                    f = new int[ts.freq.Length - 1];
                    for (int i = 0; i < ts.freq.Length - 1; i++) f[i] = ts.freq[i + 1];
                }
                seasonal.ts = new TimeSeries(season_, f);

                if (f != null)
                    seasonal.Solve();
            }
        }
Ejemplo n.º 3
0
        public static Model ModelQuick(TimeSeries ts)
        {
            Model m = new Model();
            m.ts = ts;
            m.seasonal = null;
            m.values = null;
            m.errors = null;

            m.type = ModelType.Explicit;
            m.Solve();
            m.CalcError();
               // m.ComputeErrorRange();
            m.error = m.Error(Global.confidence);
            m.len = ts.Length;
            return m;
        }
Ejemplo n.º 4
0
        public void Solve()
        {
            if (type == ModelType.PLA)
            {
                values = new double[2];
                double asum = 0;
                double bsum = 0;

                for (int i = 0; i < this.ts.Length; i++)
                {
                    asum += ((i + 1) - ((ts.Length + 1) / 2)) * ts.data[i];
                    bsum += ((i + 1) - ((2 * ts.Length + 1) / 3)) * ts.data[i];
                }
                values[0] = 12 * asum / ts.Length / (ts.Length + 1) / (ts.Length - 1);
                values[1] = 6 * bsum / ts.Length / (1 - ts.Length);
                return;
            }

            int n = ts.Length;
            int l = 0;

            freq = ts.freq[0];
            while (freq > ts.Length)
            {
                if (l == ts.freq.Length)
                {
                    return;
                }
                freq = ts.freq[l++];
            }

            if (freq == 0)
            {
                //use regression
                values   = ChebyshevReg.Solve(ts.data);
                seasonal = null;
            }
            else
            {
                double[] season_ = new double[freq];
                decompose(n, freq, season_);
                seasonal = new Model();
                int[] f;
                if (ts.freq.Length == 1)
                {
                    f = null;
                }
                else
                {
                    f = new int[ts.freq.Length - 1];
                    for (int i = 0; i < ts.freq.Length - 1; i++)
                    {
                        f[i] = ts.freq[i + 1];
                    }
                }
                seasonal.ts = new TimeSeries(season_, f);

                if (f != null)
                {
                    seasonal.Solve();
                }
            }
        }