private bool checkConvergence()
{
if (maxIterations > 0 && CurrentIteration >= maxIterations)
return true;
if (tolerance > 0)
{
// Stopping criteria is likelihood convergence
double delta = Math.Abs(OldValue - NewValue);
if (delta <= tolerance * Math.Abs(OldValue))
return true;
}
// Check if we have reached an invalid or perfectly separable answer
if (Double.IsNaN(NewValue) || Double.IsInfinity(NewValue))
return true;
return false;
}