#NEWLINE# def _switch( self , r , nr ) : #NEWLINE# #INDENT# '\n        Calculate the r frontier where we must switch from Nr to Sr\n        when estimating E[Nr].\n        ' #NEWLINE# for ( i , r_ ) in enumerate ( std ) : #NEWLINE# #INDENT# if ( ( len ( r ) == ( i + 1 ) ) or ( r [ ( i + 1 ) ] != ( r_ + 1 ) ) ) : #NEWLINE# #INDENT# self . _switch_at = r_ #NEWLINE# break #NEWLINE# #UNINDENT# Sr = self . smoothedNr #NEWLINE# smooth_r_star = ( ( ( r_ + 1 ) * Sr ( ( r_ + 1 ) ) ) / Sr ( r_ ) ) #NEWLINE# unsmooth_r_star = ( ( ( r_ + 1 ) * nr [ ( i + 1 ) ] ) / nr [ i ] ) #NEWLINE# std = math . sqrt ( self . _variance ( r_ , nr [ i ] , nr [ ( i + 1 ) ] ) ) #NEWLINE# if ( abs ( ( unsmooth_r_star - smooth_r_star ) ) <= ( 1.96 * std ) ) : #NEWLINE# #INDENT# self . _switch_at = r_ #NEWLINE# break