def log_likelihood(y, yhat): '''Helper function to compute the log likelihood.''' eps = np.spacing(1) return np.nansum(y * np.log(eps + yhat) - yhat)