mlpy.optimize.utils.is_converged

mlpy.optimize.utils.is_converged(fval, prev_fval, thresh=0.0001, warn=False)[source]

Check if an objective function has converged.

Parameters:

fval : float

The current value.

prev_fval : float

The previous value.

thresh : float

The convergence threshold.

warn : bool

Flag indicating whether to warn the user when the fval decreases.

Returns:

bool :

Flag indicating whether the objective function has converged or not.

Notes

The test returns true if the slope of the function falls below the threshold; i.e.

\frac{|f(t) - f(t-1)|}{\text{avg}} < \text{thresh},

where

\text{avg} = \frac{|f(t)| + |f(t+1)|}{2}

Note

Ported from Matlab:

Copyright (2010) Kevin Murphy and Matt Dunham
License: MIT