def psicomputations(variance, Z, variational_posterior, return_psi2_n=False):
<EOL>mu = variational_posterior.mean<EOL>S = variational_posterior.variance<EOL>psi0 = (variance*(np.square(mu)+S)).sum(axis=<NUM_LIT:1>)<EOL>Zv = variance * Z<EOL>psi1 = np.dot(mu,Zv.T)<EOL>if return_psi2_n:<EOL><INDENT>psi2 = psi1[:,:,None] * psi1[:,None,:] + np.dot(S[:,None,:] * Zv[None,:,:], Zv.T)<EOL><DEDENT>else:<EOL><INDENT>psi2 = np.dot(S.sum(axis=<NUM_LIT:0>) * Zv, Zv.T) + tdot(psi1.T)<EOL><DEDENT>return psi0, psi1, psi2<EOL>
Compute psi-statistics for ss-linear kernel