Skip to content

Commit

Permalink
update the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Yichao Zhou committed Dec 26, 2015
1 parent b2e59e8 commit 8486838
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,18 @@ something like:
import numpy as np
def logprob(x, ivar):
logp = -0.5 * np.sum(ivar * x**2)
return logp
def logprob_grad(x, ivar):
grad = -ivar * x
return logp, grad
return grad
```

```
from pyhmc import hmc
ivar = 1. / np.random.rand(5)
samples = hmc(logprob, x0=np.random.randn(5), args=(ivar,), n_samples=1e4)
samples = hmc(logprob, logprob_grad, x0=np.random.randn(5),
args=(ivar,), n_samples=1e4)
```

```
Expand Down
8 changes: 6 additions & 2 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,20 @@ If you wanted to draw samples from a 5 dimensional Gaussian, you would do someth
import numpy as np
def logprob(x, ivar):
logp = -0.5 * np.sum(ivar * x**2)
return logp
def logprob_grad(x, ivar):
grad = -ivar * x
return logp, grad
return grad
.. code-block:: python
# run the sampler
from pyhmc import hmc
ivar = 1. / np.random.rand(5)
samples = hmc(logprob, x0=np.random.randn(5), args=(ivar,), n_samples=1e4)
samples = hmc(logprob, logprob_grad, x0=np.random.randn(5),
args=(ivar,), n_samples=1e4)
.. code-block:: python
Expand Down

0 comments on commit 8486838

Please sign in to comment.