Example #1
0
        public static object AutoCorrelations(double[,] Data, object BackwardTooOpt)
        {
            bool backwardsToo = Utils.GetOptionalParameter(BackwardTooOpt, false);

            int nData = Data.GetLength(0), nVars = Data.GetLength(1);

            if (nVars != 2)
            {
                throw new Exception("Error, Autocorrelations currently only calculated for 1 pair!");
            }

            object[,] ret = new object[nData, 3];
            ret[0, 0]     = "Lag";
            ret[0, 1]     = "NumData";
            ret[0, 2]     = "Correlation";

            double[] independent = Data.Column(0);
            double[] dependent   = Data.Column(1);
            for (int i = 0; i < nData - 1; ++i)
            {
                double[]            x  = independent.Submatrix(0, nData - 1 - i);
                double[]            y  = dependent.Submatrix(i, nData - 1);
                DependenceContainer sc = new DependenceContainer();

                for (int j = 0; j < x.Length; ++j)
                {
                    sc.Add(x[j], y[j]);
                }

                ret[i + 1, 0] = i;
                ret[i + 1, 1] = x.Length;
                ret[i + 1, 2] = sc.Correlation;
            }

            return(ret);
        }
Example #2
0
 private void RegisterServices(IServiceCollection services)
 {
     DependenceContainer.RegisterServices(services);
 }