Skip to content

Sample ppc does not shuffle by default #3212

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
Oct 7, 2018
Merged
Changes from all commits
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
3 changes: 2 additions & 1 deletion RELEASE-NOTES.md
Original file line number Diff line number Diff line change
@@ -6,8 +6,9 @@

- Track the model log-likelihood as a sampler stat for NUTS and HMC samplers
(accessible as `trace.get_sampler_stats('model_logp')`) (#3134)
- Add Incomplete Beta function `incomplete_beta(a, b, value)`
- Add Incomplete Beta function `incomplete_beta(a, b, value)`
- Add log CDF functions to continuous distributions: `Beta`, `Cauchy`, `ExGaussian`, `Exponential`, `Flat`, `Gumbel`, `HalfCauchy`, `HalfFlat`, `HalfNormal`, `Laplace`, `Logistic`, `Lognormal`, `Normal`, `Pareto`, `StudentT`, `Triangular`, `Uniform`, `Wald`, `Weibull`.
- Behavior of `sample_posterior_predictive` is now to produce posterior predictive samples, in order, from all values of the `trace`. Previously, by default it would produce 1 chain worth of samples, using a random selection from the `trace` (#3212)

### Maintenance

8 changes: 4 additions & 4 deletions pymc3/sampling.py
Original file line number Diff line number Diff line change
@@ -1098,7 +1098,7 @@ def sample_posterior_predictive(trace, samples=None, model=None, vars=None, size
nchain = 1

if samples is None:
samples = len(trace)
samples = sum(len(v) for v in trace._straces.values())

model = modelcontext(model)

@@ -1108,7 +1108,7 @@ def sample_posterior_predictive(trace, samples=None, model=None, vars=None, size
if random_seed is not None:
np.random.seed(random_seed)

indices = np.random.randint(0, nchain * len_trace, samples)
indices = np.arange(samples)

if progressbar:
indices = tqdm(indices, total=samples)
@@ -1126,9 +1126,9 @@ def sample_posterior_predictive(trace, samples=None, model=None, vars=None, size
for slc, idx in enumerate(indices):
if nchain > 1:
chain_idx, point_idx = np.divmod(idx, len_trace)
param = trace._straces[chain_idx].point(point_idx)
param = trace._straces[chain_idx % nchain].point(point_idx)
Copy link
Member

Choose a reason for hiding this comment

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

Fancy ;-)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll add a PR to numpy for my new divmodmod

else:
param = trace[idx]
param = trace[idx % len_trace]

values = draw_values(vars, point=param, size=size)
for k, v in zip(vars, values):