Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
P
pymc3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ynic-debian
pymc3
Commits
4a37e24d
Commit
4a37e24d
authored
Mar 24, 2020
by
Robert P. Goldman
Committed by
rpgoldman
Mar 26, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix docstrings.
The layout of parameters sections was wrong. Also pruned some dead code.
parent
6699447b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
58 deletions
+10
-58
pymc3/distributions/posterior_predictive.py
pymc3/distributions/posterior_predictive.py
+10
-58
No files found.
pymc3/distributions/posterior_predictive.py
View file @
4a37e24d
...
...
@@ -137,26 +137,26 @@ def fast_sample_posterior_predictive(trace: Union[MultiTrace, Dataset, List[Dict
Parameters
----------
trace
: MultiTrace, xarray.Dataset, or List of points (dictionary)
trace: MultiTrace, xarray.Dataset, or List of points (dictionary)
Trace generated from MCMC sampling.
samples
: int, optional
samples: int, optional
Number of posterior predictive samples to generate. Defaults to one posterior predictive
sample per posterior sample, that is, the number of draws times the number of chains. It
is not recommended to modify this value; when modified, some chains may not be represented
in the posterior predictive sample.
model
: Model (optional if in `with` context)
model: Model (optional if in `with` context)
Model used to generate `trace`
var_names
: Iterable[str]
var_names: Iterable[str]
List of vars to sample.
keep_size
: bool, optional
keep_size: bool, optional
Force posterior predictive sample to have the same shape as posterior and sample stats
data: ``(nchains, ndraws, ...)``.
random_seed
: int
random_seed: int
Seed for the random number generator.
Returns
-------
samples
: dict
samples: dict
Dictionary with the variable names as keys, and values numpy arrays containing
posterior predictive samples.
"""
...
...
@@ -468,16 +468,16 @@ class _PosteriorPredictiveSampler(AbstractContextManager):
Parameters
----------
param
: number, array like, theano variable or pymc3 random variable
param: number, array like, theano variable or pymc3 random variable
The value or distribution. Constants or shared variables
will be converted to an array and returned. Theano variables
are evaluated. If `param` is a pymc3 random variable, draw
values from it and return that (as ``np.ndarray``), unless a
value is specified in the ``trace``.
trace
: pm.MultiTrace, optional
trace: pm.MultiTrace, optional
A dictionary from pymc3 variable names to samples of their values
used to provide context for evaluating ``param``.
givens
: dict, optional
givens: dict, optional
A dictionary from theano variables to their values. These values
are used to evaluate ``param`` if it is a theano variable.
"""
...
...
@@ -609,51 +609,3 @@ def _param_shape(var_desig, model: Model) -> Tuple[int, ...]:
if
shape
==
(
1
,):
shape
=
tuple
()
return
shape
# # Posterior predictive sampling takes a "trace-like" argument that is
# # either a `pm.MultiTrace` or a dictionary that acts like a
# # trace. This smooths over that distinction
# def _trace_varnames(trace_like: TraceLike) -> List[str]:
# if hasattr(trace_like, 'varnames'):
# trace_like = cast(MultiTrace, trace_like)
# return trace_like.varnames
# elif isinstance(trace_like, list):
# varnames = [] # type: List[str]
# for tl in trace_like:
# varnames += _trace_varnames(tl)
# return varnames
# else:
# return list(trace_like.keys())
# class _PointIterator (Iterator[Dict[str, np.ndarray]]):
# new_dict = None # type: Dict[str, np.ndarray]
# def __init__(self, trace_dict: Dict[str, np.ndarray]):
# new_dict = {name : val if len(val.shape) > 1 else val.reshape(val.shape + (1,))
# for name, val in trace_dict.items() } # type: Dict[str, np.ndarray]
# def __iter__(self):
# return self.iter()
# def iter(self) --> :
# i = 0
# def ifunc():
# try:
# point = {name: trace_dict[name][i,:] for name in self.new_dict.keys()}
# yield point
# except IndexError:
# raise StopIteration
# return ifunc
# # Posterior predictive sampling takes a "trace-like" argument that is
# # either a `pm.MultiTrace` or a dictionary that acts like a
# # trace. This smooths over that distinction
# def _trace_points(trace_like: TraceLike) -> Iterator[Dict[str, Any]]:
# if isinstance(trace_like, MultiTrace):
# return trace_like.points()
# elif isinstance(trace_like, dict):
# return _PointIterator(trace_like)
# elif isinstance(trace_like, list):
# raise ValueError("Cannot make point iterator for a list of traces.")
# else:
# raise ValueError("Do not know how to make point iterator for object of type %s"%type(trace_like))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment