Skip to content

Commit 906fcdc

Browse files
Updated pymc.simulator docstring (typos, defaults, type description) (#6035)
* Updated pymc.simulator docstring (typos, defaults, type description) Co-authored-by: Oriol Abril-Pla <[email protected]>
1 parent 7a5074e commit 906fcdc

File tree

1 file changed

+23
-21
lines changed

1 file changed

+23
-21
lines changed

pymc/distributions/simulator.py

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def sum_stat(cls, *args, **kwargs):
6666
class Simulator(NoDistribution):
6767
r"""
6868
Simulator distribution, used for Approximate Bayesian Inference (ABC)
69-
with Sequential Monte Carlo (SMC) sampling via ``pm.sample_smc``.
69+
with Sequential Monte Carlo (SMC) sampling via :func:`~pymc.sample_smc`.
7070
7171
Simulator distributions have a stochastic pseudo-loglikelihood defined by
7272
a distance metric between the observed and simulated data, and tweaked
@@ -78,14 +78,17 @@ class Simulator(NoDistribution):
7878
Python random simulator function. Should expect the following signature
7979
``(rng, arg1, arg2, ... argn, size)``, where rng is a ``numpy.random.RandomStream()``
8080
and ``size`` defines the size of the desired sample.
81-
params : list
82-
Parameters used by the Simulator random function. Parameters can also
83-
be passed by order, in which case the keyword argument ``params`` is
84-
ignored. Alternatively, each parameter can be passed by order after fn,
85-
``param1, param2, ..., paramN``
86-
distance : Aesara Op, callable or str
87-
Distance function. Available options are ``"gaussian"`` (default), ``"laplace"``,
88-
``"kullback_leibler"`` or a user defined function (or Aesara Op) that takes
81+
*unnamed_params : list of TensorVariable
82+
Parameters used by the Simulator random function. Each parameter can be passed
83+
by order after fn, for example ``param1, param2, ..., paramN``. params can also
84+
be passed with keyword argument "params".
85+
params : list of TensorVariable
86+
Keyword form of ''unnamed_params''.
87+
One of unnamed_params or params must be provided.
88+
If passed both unnamed_params and params, an error is raised.
89+
distance : Aesara_Op, callable or str, default "gaussian"
90+
Distance function. Available options are ``"gaussian"``, ``"laplace"``,
91+
``"kullback_leibler"`` or a user defined function (or Aesara_Op) that takes
8992
``epsilon``, the summary statistics of observed_data and the summary statistics
9093
of simulated_data as input.
9194
@@ -98,20 +101,19 @@ class Simulator(NoDistribution):
98101
``distance="gaussian"`` + ``sum_stat="sort"`` is equivalent to the 1D 2-wasserstein distance
99102
100103
``distance="laplace"`` + ``sum_stat="sort"`` is equivalent to the the 1D 1-wasserstein distance
101-
sum_stat : Aesara Op, callable or str
102-
Summary statistic function. Available options are ``"indentity"`` (default),
103-
``"sort"``, ``"mean"``, ``"median"``. If a callable (or Aesara Op) is defined,
104+
sum_stat : Aesara_Op, callable or str, default "identity"
105+
Summary statistic function. Available options are ``"identity"``,
106+
``"sort"``, ``"mean"``, ``"median"``. If a callable (or Aesara_Op) is defined,
104107
it should return a 1d numpy array (or Aesara vector).
105-
epsilon : float or array
108+
epsilon : tensor_like of float, default 1.0
106109
Scaling parameter for the distance functions. It should be a float or
107-
an array of the same size of the output of ``sum_stat``. Defaults to ``1.0``
108-
ndim_supp : int
110+
an array of the same size of the output of ``sum_stat``.
111+
ndim_supp : int, default 0
109112
Number of dimensions of the SimulatorRV (0 for scalar, 1 for vector, etc.)
110-
Defaults to ``0``.
111-
ndims_params : list[int]
113+
ndims_params : list of int, optional
112114
Number of minimum dimensions of each parameter of the RV. For example,
113115
if the Simulator accepts two scalar inputs, it should be ``[0, 0]``.
114-
Defaults to ``0`` for each parameter.
116+
Default to list of 0 with length equal to the number of parameters.
115117
116118
Examples
117119
--------
@@ -158,7 +160,7 @@ def __new__(
158160
elif distance == "kullback_leibler":
159161
raise NotImplementedError("KL not refactored yet")
160162
# TODO: Wrap KL in aesara OP
161-
# distance = KullbackLiebler(observed)
163+
# distance = KullbackLeibler(observed)
162164
# if sum_stat != "identity":
163165
# _log.info(f"Automatically setting sum_stat to identity as expected by {distance}")
164166
# sum_stat = "identity"
@@ -273,8 +275,8 @@ def laplace(epsilon, obs_data, sim_data):
273275
return -at.abs_((obs_data - sim_data) / epsilon)
274276

275277

276-
class KullbackLiebler:
277-
"""Approximate Kullback-Liebler."""
278+
class KullbackLeibler:
279+
"""Approximate Kullback-Leibler."""
278280

279281
def __init__(self, obs_data):
280282
if obs_data.ndim == 1:

0 commit comments

Comments
 (0)