tensorflow / tensorflow/probability

Possible error in `tfp.mcmc.HamiltonianMonteCarlo` API documentation

Open
#1,449 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Jupyter Notebook
Stars
4.4k
Forks
1.1k
PR merge metrics
No merged PRs in 30d

Description

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

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the first example on the linked HamiltonianMonteCarlo API documentation page and compare its stated standard normal target with the supplied unnormalized_log_prob function. Done means the example's description, function, and demonstrated output consistently represent a standard univariate normal distribution.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
documentation, machine-learning
Issue type
Documentation
Difficulty
1/5
Estimated time
Under an hour
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.