def moments_match_ep(self,obs,tau,v,Y_metadata_i=None):
<EOL>mu = v/tau<EOL>sigma2 = <NUM_LIT:1.>/tau<EOL>f_min = mu - <NUM_LIT:20>*np.sqrt(sigma2)<EOL>f_max = mu + <NUM_LIT:20>*np.sqrt(sigma2)<EOL>def int_1(f):<EOL><INDENT>return self.pdf(f, obs, Y_metadata=Y_metadata_i)*np.exp(-<NUM_LIT:0.5>*tau*np.square(mu-f))<EOL><DEDENT>z_scaled, accuracy = quad(int_1, f_min, f_max)<EOL>def int_2(f):<EOL><INDENT>return f*self.pdf(f, obs, Y_metadata=Y_metadata_i)*np.exp(-<NUM_LIT:0.5>*tau*np.square(mu-f))<EOL><DEDENT>mean, accuracy = quad(int_2, f_min, f_max)<EOL>mean /= z_scaled<EOL>def int_3(f):<EOL><INDENT>return (f**<NUM_LIT:2>)*self.pdf(f, obs, Y_metadata=Y_metadata_i)*np.exp(-<NUM_LIT:0.5>*tau*np.square(mu-f))<EOL><DEDENT>Ef2, accuracy = quad(int_3, f_min, f_max)<EOL>Ef2 /= z_scaled<EOL>variance = Ef2 - mean**<NUM_LIT:2><EOL>z = z_scaled/np.sqrt(<NUM_LIT:2>*np.pi/tau)<EOL>return z, mean, variance<EOL>
Calculation of moments using quadrature

:param obs: observed output
:param tau: cavity distribution 1st natural parameter (precision)
:param v: cavity distribution 2nd natural paramenter (mu*precision)