예제 #1
0
        /// <summary>
        /// Estimates the unbiased population variance from the provided samples.
        /// On a dataset of size N will use an N-1 normalizer (Bessel's correction).
        /// Returns NaN if data has less than two entries or if any entry is NaN.
        /// </summary>
        /// <param name="samples">A subset of samples, sampled from the full population.</param>
        public static double Variance(this IEnumerable <double> samples)
        {
            var array = samples as double[];

            return(array != null
                ? ArrayStatistics.Variance(array)
                : StreamingStatistics.Variance(samples));
        }
예제 #2
0
 /// <summary>
 /// Estimates the unbiased population variance from the provided samples.
 /// On a dataset of size N will use an N-1 normalizer (Bessel's correction).
 /// Returns NaN if data has less than two entries or if any entry is NaN.
 /// Null-entries are ignored.
 /// </summary>
 /// <param name="samples">A subset of samples, sampled from the full population.</param>
 public static double Variance(this IEnumerable <double?> samples)
 {
     if (samples == null)
     {
         throw new ArgumentNullException("samples");
     }
     return(StreamingStatistics.Variance(samples.Where(d => d.HasValue).Select(d => d.Value)));
 }
예제 #3
0
 /// <summary>
 /// Estimates the unbiased population variance from the provided samples.
 /// On a dataset of size N will use an N-1 normalizer (Bessel's correction).
 /// Returns NaN if data has less than two entries or if any entry is NaN.
 /// Null-entries are ignored.
 /// </summary>
 /// <param name="samples">A subset of samples, sampled from the full population.</param>
 public static double Variance(this IEnumerable <double?> samples)
 {
     return(StreamingStatistics.Variance(samples.Where(d => d.HasValue).Select(d => d.Value)));
 }