예제 #1
0
        /// <summary>
        /// Computes the weighted average of the data currently stored in the window.
        /// </summary>
        /// <param name="weights">The weights.</param>
        public WeightedAvg GetDataWeightedAvg(double[] weights)
        {
            CheckReadyness(weights.Length);
            int         numOfSamplesToBeProcessed = weights.Length;
            WeightedAvg wAvg = new WeightedAvg();

            for (int i = numOfSamplesToBeProcessed - 1, j = 0; i >= 0; i--, j++)
            {
                wAvg.AddSample(_dataQueue.GetElementAt(i, true), weights[j]);
            }
            return(wAvg);
        }
예제 #2
0
        /// <summary>
        /// Computes the linearly weighted average of the differences of the data in the window.
        /// </summary>
        /// <param name="reqNumOfSamples">The requiered mumber of samples (-1 means all).</param>
        public WeightedAvg GetDataDiffLinWeightedAvg(int reqNumOfSamples = -1)
        {
            int numOfSamplesToBeProcessed = reqNumOfSamples == -1 ? _dataQueue.Count : reqNumOfSamples;

            CheckReadyness(numOfSamplesToBeProcessed);
            WeightedAvg wAvg = new WeightedAvg();

            for (int i = numOfSamplesToBeProcessed - 2, w = 1; i >= 0; i--, w++)
            {
                wAvg.AddSample(_dataQueue.GetElementAt(i, true) - _dataQueue.GetElementAt(i + 1, true));
            }
            return(wAvg);
        }