Helps sample from library distributions.
Useful for 1-dimensional distributions.
With a good proposal IS is more efficient than RS.
function f(a, b)
c = a*b
d = sin(c)
d
end
function f(a, da, b, db)
c, dc = a*b, da*b + a*db
d, dd = sin(c), dc * cos(c)
d, dd
end
function f(a,b)
c = a*b
if c > 0
d = log(c)
else
d = sin(c)
end
d
end
a=2, b=3
c=a*b=6
d=log(c)=1.791
d=1.791
a=2, b=3, da=1, db=0
c=a*b=6, dc=da*b + a*db=3
d=log(c)=1.791, dd=dc*(1/c)=0.5
d=1.791, dd=0.5
Hamiltonian MC is based on statistical physics: