/// <summary> /// Evaluates the harmonic mean. /// Returns NaN if data is empty or if any entry is NaN. /// </summary> /// <param name="data">The data to calculate the harmonic mean of.</param> /// <returns>The harmonic mean of the sample.</returns> public static double HarmonicMean(this IEnumerable <double> data) { var array = data as double[]; return(array != null ? ArrayStatistics.HarmonicMean(array) : StreamingStatistics.HarmonicMean(data)); }