@ -30,6 +30,7 @@
using System ;
using System.Collections.Generic ;
using System.Linq ;
using MathNet.Numerics.Properties ;
namespace MathNet.Numerics.Statistics
@ -155,6 +156,16 @@ namespace MathNet.Numerics.Statistics
return any ? mean : double . NaN ;
}
/// <summary>
/// Estimates the arithmetic sample mean from the enumerable, in a single pass without memoization.
/// Returns NaN if data is empty or any entry is NaN.
/// </summary>
/// <param name="stream">Sample stream, no sorting is assumed.</param>
public static double Mean ( IEnumerable < float > stream )
{
return Mean ( stream . Select ( x = > ( double ) x ) ) ;
}
/// <summary>
/// Evaluates the geometric mean of the enumerable, in a single pass without memoization.
/// Returns NaN if data is empty or any entry is NaN.
@ -226,6 +237,17 @@ namespace MathNet.Numerics.Statistics
return count > 1 ? variance / ( count - 1 ) : double . NaN ;
}
/// <summary>
/// Estimates the unbiased population variance from the provided samples as enumerable sequence, in a single pass without memoization.
/// 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">Sample stream, no sorting is assumed.</param>
public static double Variance ( IEnumerable < float > samples )
{
return Variance ( samples . Select ( x = > ( double ) x ) ) ;
}
/// <summary>
/// Evaluates the population variance from the full population provided as enumerable sequence, in a single pass without memoization.
/// On a dataset of size N will use an N normalizer and would thus be biased if applied to a subset.
@ -259,6 +281,17 @@ namespace MathNet.Numerics.Statistics
return variance / count ;
}
/// <summary>
/// Evaluates the population variance from the full population provided as enumerable sequence, in a single pass without memoization.
/// On a dataset of size N will use an N normalizer and would thus be biased if applied to a subset.
/// Returns NaN if data is empty or if any entry is NaN.
/// </summary>
/// <param name="population">Sample stream, no sorting is assumed.</param>
public static double PopulationVariance ( IEnumerable < float > population )
{
return PopulationVariance ( population . Select ( x = > ( double ) x ) ) ;
}
/// <summary>
/// Estimates the unbiased population standard deviation from the provided samples as enumerable sequence, in a single pass without memoization.
/// On a dataset of size N will use an N-1 normalizer (Bessel's correction).
@ -270,6 +303,17 @@ namespace MathNet.Numerics.Statistics
return Math . Sqrt ( Variance ( samples ) ) ;
}
/// <summary>
/// Estimates the unbiased population standard deviation from the provided samples as enumerable sequence, in a single pass without memoization.
/// 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">Sample stream, no sorting is assumed.</param>
public static double StandardDeviation ( IEnumerable < float > samples )
{
return Math . Sqrt ( Variance ( samples ) ) ;
}
/// <summary>
/// Evaluates the population standard deviation from the full population provided as enumerable sequence, in a single pass without memoization.
/// On a dataset of size N will use an N normalizer and would thus be biased if applied to a subset.
@ -281,6 +325,17 @@ namespace MathNet.Numerics.Statistics
return Math . Sqrt ( PopulationVariance ( population ) ) ;
}
/// <summary>
/// Evaluates the population standard deviation from the full population provided as enumerable sequence, in a single pass without memoization.
/// On a dataset of size N will use an N normalizer and would thus be biased if applied to a subset.
/// Returns NaN if data is empty or if any entry is NaN.
/// </summary>
/// <param name="population">Sample stream, no sorting is assumed.</param>
public static double PopulationStandardDeviation ( IEnumerable < float > population )
{
return Math . Sqrt ( PopulationVariance ( population ) ) ;
}
/// <summary>
/// Estimates the arithmetic sample mean and the unbiased population variance from the provided samples as enumerable sequence, in a single pass without memoization.
/// On a dataset of size N will use an N-1 normalizer (Bessel's correction).
@ -318,6 +373,17 @@ namespace MathNet.Numerics.Statistics
count > 1 ? variance / ( count - 1 ) : double . NaN ) ;
}
/// <summary>
/// Estimates the arithmetic sample mean and the unbiased population variance from the provided samples as enumerable sequence, in a single pass without memoization.
/// On a dataset of size N will use an N-1 normalizer (Bessel's correction).
/// Returns NaN for mean if data is empty or any entry is NaN, and NaN for variance if data has less than two entries or if any entry is NaN.
/// </summary>
/// <param name="samples">Sample stream, no sorting is assumed.</param>
public static Tuple < double , double > MeanVariance ( IEnumerable < float > samples )
{
return MeanVariance ( samples . Select ( x = > ( double ) x ) ) ;
}
/// <summary>
/// Estimates the arithmetic sample mean and the unbiased population standard deviation from the provided samples as enumerable sequence, in a single pass without memoization.
/// On a dataset of size N will use an N-1 normalizer (Bessel's correction).
@ -330,6 +396,17 @@ namespace MathNet.Numerics.Statistics
return new Tuple < double , double > ( meanVariance . Item1 , Math . Sqrt ( meanVariance . Item2 ) ) ;
}
/// <summary>
/// Estimates the arithmetic sample mean and the unbiased population standard deviation from the provided samples as enumerable sequence, in a single pass without memoization.
/// On a dataset of size N will use an N-1 normalizer (Bessel's correction).
/// Returns NaN for mean if data is empty or any entry is NaN, and NaN for standard deviation if data has less than two entries or if any entry is NaN.
/// </summary>
/// <param name="samples">Sample stream, no sorting is assumed.</param>
public static Tuple < double , double > MeanStandardDeviation ( IEnumerable < float > samples )
{
return MeanStandardDeviation ( samples . Select ( x = > ( double ) x ) ) ;
}
/// <summary>
/// Estimates the unbiased population covariance from the provided two sample enumerable sequences, in a single pass without memoization.
/// On a dataset of size N will use an N-1 normalizer (Bessel's correction).
@ -432,6 +509,16 @@ namespace MathNet.Numerics.Statistics
return any ? Math . Sqrt ( mean ) : double . NaN ;
}
/// <summary>
/// Estimates the root mean square (RMS) also known as quadratic mean from the enumerable, in a single pass without memoization.
/// Returns NaN if data is empty or any entry is NaN.
/// </summary>
/// <param name="stream">Sample stream, no sorting is assumed.</param>
public static double RootMeanSquare ( IEnumerable < float > stream )
{
return RootMeanSquare ( stream . Select ( x = > ( double ) x ) ) ;
}
/// <summary>
/// Calculates the entropy of a stream of double values.
/// Returns NaN if any of the values in the stream are NaN.