Beispiel #1
0
        /// <summary>
        /// Estimates the sample mean.
        /// Returns NaN if data is empty or if any entry is NaN.
        /// </summary>
        /// <param name="data">The data to calculate the mean of.</param>
        /// <returns>The mean of the sample.</returns>
        public static double Mean(this IEnumerable <double> data)
        {
            var array = data as double[];

            return(array != null
                ? ArrayStatistics.Mean(array)
                : StreamingStatistics.Mean(data));
        }
Beispiel #2
0
 /// <summary>
 /// Estimates the sample 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>
 /// <returns>The mean of the sample.</returns>
 public static double Mean(this IEnumerable <double?> data)
 {
     if (data == null)
     {
         throw new ArgumentNullException("data");
     }
     return(StreamingStatistics.Mean(data.Where(d => d.HasValue).Select(d => d.Value)));
 }
Beispiel #3
0
 /// <summary>
 /// Estimates the sample 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>
 /// <returns>The mean of the sample.</returns>
 public static double Mean(this IEnumerable <double?> data)
 {
     return(StreamingStatistics.Mean(data.Where(d => d.HasValue).Select(d => d.Value)));
 }