def _resample_nu(self, tau, N_steps=<NUM_LIT:100>, prop_std=<NUM_LIT:0.1>, alpha=<NUM_LIT:1>, beta=<NUM_LIT:1>):
<EOL>taus = [tau] if isinstance(tau, np.ndarray) else tau<EOL>N = <NUM_LIT:0><EOL>E_tau = <NUM_LIT:0><EOL>E_logtau = <NUM_LIT:0><EOL>for tau in taus:<EOL><INDENT>bad = ~np.isfinite(tau)<EOL>N += np.sum(~bad)<EOL>E_tau += np.sum(tau[~bad])<EOL>E_logtau += np.sum(np.log(tau[~bad]))<EOL><DEDENT>if N > <NUM_LIT:0>:<EOL><INDENT>E_tau /= N<EOL>E_logtau /= N<EOL><DEDENT>lprior = lambda nu: (alpha - <NUM_LIT:1>) * np.log(nu) - alpha * nu<EOL>ll = lambda nu: N * (nu/<NUM_LIT:2> * np.log(nu/<NUM_LIT:2>)  - gammaln(nu/<NUM_LIT:2>) + (nu/<NUM_LIT:2> - <NUM_LIT:1>) * E_logtau - nu/<NUM_LIT:2> * E_tau)<EOL>lp = lambda nu: ll(nu) + lprior(nu)<EOL>lp_curr = lp(self.nu)<EOL>for step in range(N_steps):<EOL><INDENT>nu_new = self.nu + prop_std * np.random.randn()<EOL>if nu_new <<NUM_LIT>:<EOL><INDENT>continue<EOL><DEDENT>lp_new = lp(nu_new)<EOL>if np.log(np.random.rand()) < lp_new - lp_curr:<EOL><INDENT>self.nu = nu_new<EOL>lp_curr = lp_new<EOL><DEDENT><DEDENT>
Update the degree of freedom parameter with 
Metropolis-Hastings. Assume a prior nu ~ Ga(alpha, beta) 
and use a proposal nu' ~ N(nu, prop_std^2). If proposals
are negative, reject automatically due to likelihood.