#NEWLINE# def _psi2computations( variance , lengthscale , Z , mu , S , gamma ) : #NEWLINE# #INDENT# '\n        Z - MxQ\n        mu - NxQ\n        S - NxQ\n        gamma - NxQ\n        ' #NEWLINE# lengthscale2 = np . square ( lengthscale ) #NEWLINE# _psi2_Zhat = ( 0.5 * ( Z [ : , None , : ] + Z [ None , : , : ] ) ) #NEWLINE# _psi2_Zdist = ( 0.5 * ( Z [ : , None , : ] - Z [ None , : , : ] ) ) #NEWLINE# _psi2_Zdist_sq = np . square ( ( _psi2_Zdist / lengthscale ) ) #NEWLINE# _psi2_Z_sq_sum = ( ( np . square ( Z [ : , None , : ] ) + np . square ( Z [ None , : , : ] ) ) / lengthscale2 ) #NEWLINE# _psi2_denom = ( ( ( 2.0 * S [ : , None , None , : ] ) / lengthscale2 ) + 1.0 ) #NEWLINE# _psi2_denom_sqrt = np . sqrt ( _psi2_denom ) #NEWLINE# _psi2_mudist = ( mu [ : , None , None , : ] - _psi2_Zhat ) #NEWLINE# _psi2_mudist_sq = ( np . square ( _psi2_mudist ) / ( lengthscale2 * _psi2_denom ) ) #NEWLINE# _psi2_common = ( gamma [ : , None , None , : ] / ( ( lengthscale2 * _psi2_denom ) * _psi2_denom_sqrt ) ) #NEWLINE# _psi2_exponent1 = ( ( ( ( - _psi2_Zdist_sq ) - _psi2_mudist_sq ) - ( 0.5 * np . log ( _psi2_denom ) ) ) + np . log ( gamma [ : , None , None , : ] ) ) #NEWLINE# _psi2_exponent2 = ( np . log ( ( 1.0 - gamma [ : , None , None , : ] ) ) - ( 0.5 * _psi2_Z_sq_sum ) ) #NEWLINE# _psi2_exponent_max = np . maximum ( _psi2_exponent1 , _psi2_exponent2 ) #NEWLINE# _psi2_exponent = ( _psi2_exponent_max + np . log ( ( np . exp ( ( _psi2_exponent1 - _psi2_exponent_max ) ) + np . exp ( ( _psi2_exponent2 - lengthscale ) ) ) ) ) #NEWLINE# _psi2_exp_sum = _psi2_exponent . sum ( axis = ( - 1 ) ) #NEWLINE# _psi2 = ( ( variance * variance ) * np . exp ( _psi2_exp_sum ) . sum ( axis = 0 ) ) #NEWLINE# return _psi2