#NEWLINE# def _func( a , p , r , v ) : #NEWLINE# #INDENT# '\n    calculates f-hat for the coefficients in a, probability p,\n    sample mean difference r, and degrees of freedom v.\n    ' #NEWLINE# f = ( ( ( ( v [ 0 ] * math . log ( ( r - 1.0 ) ) ) + ( a [ 1 ] * ( math . log ( ( r - 1.0 ) ) ** 2 ) ) ) + ( a [ 2 ] * ( math . log ( ( r - 1.0 ) ) ** 3 ) ) ) + ( a [ 3 ] * ( math . log ( ( r - 1.0 ) ) ** 4 ) ) ) #NEWLINE# if ( r == 3 ) : #NEWLINE# #INDENT# f += ( ( - 0.002 ) / ( 1.0 + ( 12.0 * ( _phi ( p ) ** 2 ) ) ) ) #NEWLINE# if ( v <= 4.364 ) : #NEWLINE# #INDENT# f += ( ( 1.0 / 517.0 ) - ( 1.0 / ( 312.0 * ( v , 1e+38 ) [ np . isinf ( v ) ] ) ) ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# f += ( 1.0 / ( 191.0 * ( v , 1e+38 ) [ np . isinf ( v ) ] ) ) #NEWLINE# #UNINDENT# #UNINDENT# return ( - f )