vectorize the logPhi calculation for speed