Skip to content
This repository was archived by the owner on Mar 19, 2021. It is now read-only.

Commit 64be205

Browse files
committed
improvements for documentation
1 parent 70b073d commit 64be205

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

doc/avoiding_recompilation.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ whenever possible. If the same model is going to be used repeatedly, we would
1111
like to compile it just once. The following demonstrates how to reuse a model in
1212
different scripts and between interactive Python sessions.
1313

14-
**Within sessions** you can avoid recompiling a model in two ways. The simplest
14+
**Within sessions** you can avoid recompiling a model in two ways. The first
1515
method is to reuse a fit object in the call to ``stan``. For example,
1616

1717
.. code-block:: python
@@ -45,8 +45,10 @@ method is to reuse a fit object in the call to ``stan``. For example,
4545
fit2 = stan(fit=fit, data=new_data)
4646
print(fit2)
4747
48-
Alternatively, we can compile the model once using the ``StanModel`` class and
49-
then sample from the model using the ``sampling`` method.
48+
However, calling ``pystan.stan`` is deprecated and will soon be removed from
49+
PyStan. The recommended method is to compile the model once using the
50+
``StanModel`` class and then sample from the model using the ``sampling``
51+
method.
5052

5153
.. code-block:: python
5254

doc/getting_started.rst

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
Getting started
77
=================
88

9-
PyStan is the `Python <http://python.org>`_ interface for `Stan <http://mc-stan.org/>`_.
9+
PyStan is the `Python <http://python.org>`_ interface for
10+
`Stan <http://mc-stan.org/>`_.
1011

1112
Prerequisites
1213
=============
@@ -108,8 +109,8 @@ which studied coaching effects from eight schools.
108109
'y': [28, 8, -3, 7, -1, 1, 18, 12],
109110
'sigma': [15, 10, 16, 11, 9, 11, 10, 18]}
110111
111-
fit = pystan.stan(model_code=schools_code, data=schools_dat,
112-
iter=1000, chains=4)
112+
sm = pystan.StanModel(model_code=schools_code)
113+
fit = sm.sampling(data=schools_dat, iter=1000, chains=4)
113114
114115
In this model, we let ``theta`` be transformed parameters of ``mu`` and ``eta``
115116
instead of directly declaring theta as parameters. By parameterizing this way,
@@ -121,17 +122,16 @@ our working directory and use the following call to ``stan`` instead:
121122

122123
.. code-block:: python
123124
124-
fit1 = pystan.stan(file='8schools.stan', data=schools_dat, iter=1000, chains=4)
125+
sm = pystan.StanModel(file='8schools.stan')
126+
fit = sm.sampling(data=schools_dat, iter=1000, chains=4)
125127
126-
Once a model is fitted, we can use the fitted result as an input to the model
127-
with other data or settings. This saves us time compiling the C++ code for the
128-
model. By specifying the parameter ``fit`` for the ``stan`` function, we can fit
129-
the model again. For example, if we want to sample more iterations, we proceed
130-
as follows:
128+
Once a model is compiled, we can use the StanModel object multiple times.
129+
This saves us time compiling the C++ code for the model. For example, if we
130+
want to sample more iterations, we proceed as follows:
131131

132132
.. code-block:: python
133133
134-
fit2 = pystan.stan(fit=fit1, data=schools_dat, iter=10000, chains=4)
134+
fit2 = sm.sampling(data=schools_dat, iter=10000, chains=4)
135135
136136
The object ``fit``, returned from function ``stan`` stores samples from the
137137
posterior distribution. The ``fit`` object has a number of methods, including
@@ -154,7 +154,8 @@ parameters of interest, or just an array.
154154
155155
print(fit)
156156
157-
If `matplotlib <http://matplotlib.org/>`_ and `scipy <http://http://www.scipy.org/>`_ are installed, a visual summary may
157+
If `matplotlib <http://matplotlib.org/>`_ and
158+
`scipy <http://http://www.scipy.org/>`_ are installed, a visual summary may
158159
also be displayed using the ``plot()`` method.
159160

160161
.. code-block:: python

0 commit comments

Comments
 (0)