Browse Source

Handle empty statistics (#482)

This prevents most of the fields from being set to NaN.
pull/497/head
Lucas Godshalk 9 years ago
committed by Christoph Ruegg
parent
commit
39959e8a2e
  1. 9
      src/Numerics/Statistics/RunningStatistics.cs

9
src/Numerics/Statistics/RunningStatistics.cs

@ -237,6 +237,15 @@ namespace MathNet.Numerics.Statistics
/// </summary>
public static RunningStatistics Combine(RunningStatistics a, RunningStatistics b)
{
if (a._n == 0)
{
return b;
}
else if (b._n == 0)
{
return a;
}
long n = a._n + b._n;
double d = b._m1 - a._m1;
double d2 = d*d;

Loading…
Cancel
Save