Skip to content

Updating docs - Added an example to sampling and added sampling to the docs #1970

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 6, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions docs/source/api/data.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*****
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to add new files to the toctree in source/api.rst, or they won't show up in the documentation.

Data
*****

.. currentmodule:: pymc3.data

.. automodule:: pymc3.data
:members:
8 changes: 8 additions & 0 deletions docs/source/api/sampling.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
********
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is already in inference.rst.

Sampling
********

.. currentmodule:: pymc3.sampling

.. automodule:: pymc3.sampling
:members:
24 changes: 24 additions & 0 deletions pymc3/sampling.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,30 @@ def sample(draws, step=None, init='ADVI', n_init=200000, start=None,
-------
trace : pymc3.backends.base.MultiTrace
A `MultiTrace` object that contains the samples.

Examples
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, that was definitely missing.
nit: bad indent

--------
.. code:: ipython

>>> import pymc3 as pm
... import numpy as np
... np.random.seed(20090425)
... n = 20
... X = np.sort(3*np.random.rand(n))

Now let's set up a model and sample from it.

.. code:: ipython
>>> with pm.Model() as model:
... b0 = pm.Normal('b0', mu=0, sd=100)
... yest = b0 * X
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't do anything. Did you forget an observed var here?

...
>>> with model:
... trc = pm.sample(100)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer trace = pm.sample(2000, tune=1000, njobs=4)

...
>>> pm.df_summary(trc)
mean sd mc_error hpd_2.5 hpd_97.5
b0 7.004575 76.547562 7.654756 -161.098322 136.327346
"""
model = modelcontext(model)

Expand Down