/// <summary> /// Return the mean of the current list. /// </summary> /// <param name="lastNValues">If less than the number of items in the value list returns the mean of the lastNValues</param> /// <returns>The mean of relevant values</returns> public double CalculateMean(int lastNValues) { lock (locker) { int itemsToSkip = 0; if (lastNValues < values.Count) { itemsToSkip = values.Count - lastNValues; } List <double> itemsForMean = new List <double>(lastNValues); List <double> itemWeights = new List <double>(lastNValues); for (int i = itemsToSkip; i < values.Count; ++i) { itemsForMean.Add(values[i]); itemWeights.Add(weights[i]); } return(CommsMath.CalculateMean(itemsForMean, itemWeights)); } }
/// <summary> /// Return the mean of the current list. /// </summary> /// <returns>The mean of all values currently in the list.</returns> public double CalculateMean() { lock (locker) return(CommsMath.CalculateMean(this.values, this.weights)); }