This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
cs401r_w2016:lab10 [2016/03/17 20:39] admin |
cs401r_w2016:lab10 [2018/03/30 17:50] sadler [Description:] |
||
---|---|---|---|
Line 46: | Line 46: | ||
<code python> | <code python> | ||
import numpy as np | import numpy as np | ||
- | def p( x, t=1.0 ): | + | def p( x, temperature=1.0 ): |
- | return np.exp( -10*t*((x-2)**2) ) + 0.3*np.exp( -0.5*10*t*((x+1)**2) ) | + | return np.exp( -10*t*((x-2)**2) ) + 0.3*np.exp( -0.5*10*temperature*((x+1)**2) ) |
</code> | </code> | ||
Line 62: | Line 62: | ||
**Part 2: Hamiltonian MCMC** | **Part 2: Hamiltonian MCMC** | ||
- | For this part, you will code the Hamiltonian MCMC algorithm, as discussed in class. To do this, you will need to compute the gradient of the density function with respect to the state. An easy easy way to do this is to use the [[https://github.com/HIPS/autograd|autograd]] package: | + | For this part, you will code the Hamiltonian MCMC algorithm, as discussed in class. You will run three independent chains and report them in the same graphs. To do this, you will need to compute the gradient of the density function with respect to the state. An easy easy way to do this is to use the [[https://github.com/HIPS/autograd|autograd]] package: |
<code python> | <code python> | ||
from autograd import grad | from autograd import grad |