Esempio n. 1
0
        /// <summary>计算相关系数</summary>
        private void CorrCoefficient()
        {
            double mean = StateList.Sum() / (double)StateList.Count; //均值

            double p = StateList.Select(n => (n - mean) * (n - mean)).Sum();

            Rk = new double[LagPeriod];

            for (int i = 0; i < LagPeriod; i++)
            {
                double s1 = 0;
                for (int l = 0; l < StateList.Count - LagPeriod; l++)
                {
                    s1 += (StateList[l] - mean) * (StateList[l + i] - mean);
                }
                Rk[i] = s1 / p;
            }
        }
        /// <summary>计算相关系数</summary>
        public void CorrCoefficient()
        {
            double mean = StateList.Sum() / (double)StateList.Count;  //均值

            double p = StateList.Select(n => (n - mean) * (n - mean)).Sum();

            Rk = new double[LagPeriod];

            for (int i = 0; i < LagPeriod; i++)
            {
                double s1 = 0;
                for (int L = 0; L < (StateList.Count - LagPeriod); L++)
                {
                    s1 += (StateList[L] - mean) * (StateList[L + i] - mean);
                }
                Rk[i] = s1 / p;
            }
        }