|
|
|
@ -66,6 +66,29 @@ namespace MathNet.Numerics.Statistics |
|
|
|
return any ? min : double.NaN; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Returns the smallest value 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 float Minimum(IEnumerable<float> stream) |
|
|
|
{ |
|
|
|
var min = float.PositiveInfinity; |
|
|
|
bool any = false; |
|
|
|
|
|
|
|
foreach (var d in stream) |
|
|
|
{ |
|
|
|
if (d < min || float.IsNaN(d)) |
|
|
|
{ |
|
|
|
min = d; |
|
|
|
} |
|
|
|
|
|
|
|
any = true; |
|
|
|
} |
|
|
|
|
|
|
|
return any ? min : float.NaN; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Returns the largest value from the enumerable, in a single pass without memoization.
|
|
|
|
/// Returns NaN if data is empty or any entry is NaN.
|
|
|
|
@ -89,6 +112,29 @@ namespace MathNet.Numerics.Statistics |
|
|
|
return any ? max : double.NaN; |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Returns the largest value 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 float Maximum(IEnumerable<float> stream) |
|
|
|
{ |
|
|
|
var max = float.NegativeInfinity; |
|
|
|
bool any = false; |
|
|
|
|
|
|
|
foreach (var d in stream) |
|
|
|
{ |
|
|
|
if (d > max || float.IsNaN(d)) |
|
|
|
{ |
|
|
|
max = d; |
|
|
|
} |
|
|
|
|
|
|
|
any = true; |
|
|
|
} |
|
|
|
|
|
|
|
return any ? max : float.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.
|
|
|
|
|