/// <summary> /// Evaluates the root mean square (RMS) also known as quadratic mean. /// Returns NaN if data is empty or if any entry is NaN. /// </summary> /// <param name="data">The data to calculate the RMS of.</param> public static double RootMeanSquare(this IEnumerable <double> data) { var array = data as double[]; return(array != null ? ArrayStatistics.RootMeanSquare(array) : StreamingStatistics.RootMeanSquare(data)); }
/// <summary> /// Evaluates the root mean square (RMS) also known as quadratic mean. /// Returns NaN if data is empty or if any entry is NaN. /// Null-entries are ignored. /// </summary> /// <param name="data">The data to calculate the mean of.</param> public static double RootMeanSquare(this IEnumerable <double?> data) { return(StreamingStatistics.RootMeanSquare(data.Where(d => d.HasValue).Select(d => d.Value))); }