Skip to content

Commit f8cb9de

Browse files
committed
edits twiecki suggested, and track_progress -> progressbar
1 parent 9fb9904 commit f8cb9de

File tree

4 files changed

+28
-19
lines changed

4 files changed

+28
-19
lines changed

examples/stochastic_volatility.ipynb

Lines changed: 18 additions & 9 deletions
Large diffs are not rendered by default.

examples/stochastic_volatility.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#
2424
# $$ log(\frac{y_i}{y_{i-1}}) \sim t(\nu, 0, exp(-2 s_i)) $$
2525
#
26-
# Here, $y$ is the daily return series and $s$ is the latent volatility process.
26+
# Here, $y$ is the daily return series and $s$ is the latent log volatility process.
2727

2828
# <markdowncell>
2929

@@ -37,12 +37,13 @@
3737

3838
n = 400
3939
returns = np.genfromtxt("data/SP500.csv")[-n:]
40+
returns[:5]
4041

4142
# <markdowncell>
4243

4344
# Specifying the model in pymc mirrors its statistical specification.
4445
#
45-
# However, it is easier to sample the scale of the volatility process innovations, $\sigma$, on a log scale, so we create it using `TransformedVar` and use `logtransform`. `TransformedVar` creates one variable in the transformed space and one in the normal space. The one in the transformed space (here $\text{log}(\sigma) $) is the one over which sampling will occur, and the one in the normal space is the one to use throughout the rest of the model.
46+
# However, it is easier to sample the scale of the log volatility process innovations, $\sigma$, on a log scale, so we create it using `TransformedVar` and use `logtransform`. `TransformedVar` creates one variable in the transformed space and one in the normal space. The one in the transformed space (here $\text{log}(\sigma) $) is the one over which sampling will occur, and the one in the normal space is the one to use throughout the rest of the model.
4647
#
4748
# It takes a variable name, a distribution and a transformation to use.
4849

@@ -85,7 +86,7 @@ def hessian(point, nusd):
8586

8687
# For this model, the full maximum a posteriori (MAP) point is degenerate and has infinite density. However, if we fix `log_sigma` and `nu` it is no longer degenerate, so we find the MAP with respect to the volatility process, 's', keeping `log_sigma` and `nu` constant at their default values.
8788
#
88-
# We use [l_bfgs_b](http://en.wikipedia.org/wiki/Limited-memory_BFGS) because it is more efficient for high dimensional functions (`s` has n elements).
89+
# We use L-BFGS because it is more efficient for high dimensional functions (`s` has n elements).
8990

9091
# <codecell>
9192

@@ -113,7 +114,7 @@ def hessian(point, nusd):
113114
title(str(s))
114115
plot(trace[s][::10].T,'b', alpha=.03);
115116
xlabel('time')
116-
ylabel('volatility')
117+
ylabel('log volatility')
117118

118119
#figsize(12,6)
119120
traceplot(trace, model.vars[:-1]);
@@ -122,5 +123,5 @@ def hessian(point, nusd):
122123

123124
# ## References
124125
#
125-
# 1. Hoffman & Gelman. (2011). The No-U-Turn Sampler: Adaptively Setting Path Lengths in Hamiltonian Monte Carlo. http://arxiv.org/abs/1111.4246
126+
# 1. Hoffman & Gelman. (2011). [The No-U-Turn Sampler: Adaptively Setting Path Lengths in Hamiltonian Monte Carlo](http://arxiv.org/abs/1111.4246).
126127

pymc/sample.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
__all__ = ['sample', 'psample']
1010

11-
def sample(draws, step, start=None, trace=None, track_progress=True, model=None):
11+
def sample(draws, step, start=None, trace=None, progressbar=True, model=None):
1212
"""
1313
Draw a number of samples using the given step method.
1414
Multiple step methods supported via compound step method
@@ -25,7 +25,7 @@ def sample(draws, step, start=None, trace=None, track_progress=True, model=None)
2525
Starting point in parameter space (Defaults to trace.point(-1))
2626
trace : NpTrace
2727
A trace of past values (defaults to None)
28-
track_progress : bool
28+
progressbar : bool
2929
Flag for progress bar
3030
model : Model (optional if in `with` context)
3131
@@ -57,7 +57,7 @@ def sample(draws, step, start=None, trace=None, track_progress=True, model=None)
5757
for i in xrange(draws):
5858
point = step.step(point)
5959
trace = trace.record(point)
60-
if track_progress:
60+
if progressbar:
6161
progress.update(i)
6262

6363
return trace

readme.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ PyMC is a python module for Bayesian statistical modeling and model fitting whic
2222
## Installation
2323

2424
```
25-
git clone -b pymc3 [email protected]:pymc-devs/pymc.git
26-
python pymc/setup.py install
25+
pip install git+https://github.com/pymc-devs/pymc@pymc3
2726
```
2827

2928
### Optional

0 commit comments

Comments
 (0)