Skip to content

Commit 5eefc14

Browse files
authored
Merge pull request #2789 from ericmjl/patch-1
Parameterization docs fix for precision/standard deviations.
2 parents e6f18d8 + 01539be commit 5eefc14

File tree

2 files changed

+61
-14
lines changed

2 files changed

+61
-14
lines changed

pymc3/distributions/continuous.py

Lines changed: 55 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -269,9 +269,17 @@ class Normal(Continuous):
269269
mu : float
270270
Mean.
271271
sd : float
272-
Standard deviation (sd > 0).
272+
Standard deviation (sd > 0) (only required if tau is not specified).
273273
tau : float
274-
Precision (tau > 0).
274+
Precision (tau > 0) (only required if sd is not specified).
275+
276+
Examples
277+
--------
278+
with pm.Model():
279+
x = pm.Normal('x', mu=0, sd=10)
280+
281+
with pm.Model():
282+
x = pm.Normal('x', mu=0, tau=1/23)
275283
"""
276284

277285
def __init__(self, mu=0, sd=None, tau=None, **kwargs):
@@ -348,9 +356,17 @@ class HalfNormal(PositiveContinuous):
348356
Parameters
349357
----------
350358
sd : float
351-
Standard deviation (sd > 0).
359+
Standard deviation (sd > 0) (only required if tau is not specified).
352360
tau : float
353-
Precision (tau > 0).
361+
Precision (tau > 0) (only required if sd is not specified).
362+
363+
Examples
364+
--------
365+
with pm.Model():
366+
x = pm.HalfNormal('x', sd=10)
367+
368+
with pm.Model():
369+
x = pm.HalfNormal('x', tau=1/15)
354370
"""
355371

356372
def __init__(self, sd=None, tau=None, *args, **kwargs):
@@ -838,8 +854,19 @@ class Lognormal(PositiveContinuous):
838854
----------
839855
mu : float
840856
Location parameter.
857+
sd : float
858+
Standard deviation. (sd > 0). (only required if tau is not specified).
841859
tau : float
842-
Scale parameter (tau > 0).
860+
Scale parameter (tau > 0). (only required if sd is not specified).
861+
862+
Example
863+
-------
864+
# Example to show that we pass in only `sd` or `tau` but not both.
865+
with pm.Model():
866+
x = pm.Lognormal('x', mu=2, sd=30)
867+
868+
with pm.Model():
869+
x = pm.Lognormal('x', mu=2, tau=1/100)
843870
"""
844871

845872
def __init__(self, mu=0, sd=None, tau=None, *args, **kwargs):
@@ -930,8 +957,18 @@ class StudentT(Continuous):
930957
Degrees of freedom, also known as normality parameter (nu > 0).
931958
mu : float
932959
Location parameter.
960+
sd : float
961+
Standard deviation (sd > 0) (only required if lam is not specified)
933962
lam : float
934-
Scale parameter (lam > 0).
963+
Precision (lam > 0) (only required if sd is not specified)
964+
965+
Examples
966+
--------
967+
with pm.Model():
968+
x = pm.StudentT('x', nu=15, mu=0, sd=10)
969+
970+
with pm.Model():
971+
x = pm.StudentT('x', nu=15, mu=0, lam=1/23)
935972
"""
936973

937974
def __init__(self, nu, mu=0, lam=None, sd=None, *args, **kwargs):
@@ -1589,9 +1626,19 @@ class HalfStudentT(PositiveContinuous):
15891626
Degrees of freedom, also known as normality parameter (nu > 0).
15901627
sd : float
15911628
Scale parameter (sd > 0). Converges to the standard deviation as nu
1592-
increases
1629+
increases. (only required if lam is not specified)
15931630
lam : float
1594-
Scale parameter (lam > 0). Converges to the precision as nu increases
1631+
Scale parameter (lam > 0). Converges to the precision as nu
1632+
increases. (only required if sd is not specified)
1633+
1634+
Examples
1635+
--------
1636+
# Only pass in one of lam or sd, but not both.
1637+
with pm.Model():
1638+
x = pm.HalfStudentT('x', sd=10, nu=10)
1639+
1640+
with pm.Model():
1641+
x = pm.HalfStudentT('x', lam=4, nu=10)
15951642
"""
15961643
def __init__(self, nu=1, sd=None, lam=None, *args, **kwargs):
15971644
super(HalfStudentT, self).__init__(*args, **kwargs)

pymc3/distributions/timeseries.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,9 @@ class AR(distribution.Continuous):
8181
rho : tensor
8282
Vector of autoregressive coefficients.
8383
sd : float
84-
Standard deviation of innovation (sd > 0).
84+
Standard deviation of innovation (sd > 0). (only required if tau is not specified)
8585
tau : float
86-
Precision of innovation (tau > 0).
86+
Precision of innovation (tau > 0). (only required if sd is not specified)
8787
constant: bool (optional, default = False)
8888
Whether to include a constant.
8989
init : distribution
@@ -137,12 +137,12 @@ class GaussianRandomWalk(distribution.Continuous):
137137
138138
Parameters
139139
----------
140-
tau : tensor
141-
tau > 0, innovation precision
142-
sd : tensor
143-
sd > 0, innovation standard deviation (alternative to specifying tau)
144140
mu: tensor
145141
innovation drift, defaults to 0.0
142+
sd : tensor
143+
sd > 0, innovation standard deviation (only required if tau is not specified)
144+
tau : tensor
145+
tau > 0, innovation precision (only required if sd is not specified)
146146
init : distribution
147147
distribution for initial value (Defaults to Flat())
148148
"""

0 commit comments

Comments
 (0)