public void run ( ) { int maxruns = this . maxruns , maxsmall = this . maxsmall ; double oldchi = getChiSq ( ) ; while ( maxruns -- > 0 ) { iterate ( ) ; double newchi = getChiSq ( ) , deltachi = newchi - oldchi ; oldchi = newchi ; // stop condition: only a small improvement in Chi. if ( deltachi < 0 && deltachi > - small && -- maxsmall < 0 ) { break ; } } }
Iterate until convergence at most 100 times .