The first example given in the API documentation for tfp.mcmc.HamiltonianMonteCarlo
is sampling from the “standard univariate normal distribution”, but I think that the target_log_prob_fn
argument supplied in that example is for some other probability distribution?
# Target distribution is proportional to: `exp(-x (1 + x))`.
def unnormalized_log_prob(x):
return -x - x**2.
Running the example code unmodified returns the following result:
mean:-0.4927 stddev:0.6951 acceptance:0.6480
Modifying the example code so that unnormalized_log_prob
corresponds to the standard normal distribution (i.e. a univariate normal distribution with μ=0 and σ=1) returns the following results:
# Target distribution is proportional to: `exp(-(x**2)/2)`.
def unnormalized_log_prob(x):
return -0.5*x**2
mean:0.0306 stddev:0.9846 acceptance:0.5537