Skip to content

Commit 5629c5e

Browse files
committed
Add docstrings on Flat, HalfFlat, and Normal
1 parent 65af39b commit 5629c5e

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

pymc3/distributions/continuous.py

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,9 +228,32 @@ def __init__(self, *args, **kwargs):
228228
super(Flat, self).__init__(defaults=('_default',), *args, **kwargs)
229229

230230
def random(self, point=None, size=None):
231+
"""Raises ValueError as it is not possible to sample from Flat distribution
232+
233+
Parameters
234+
----------
235+
point : dict, optional
236+
size : int, optional
237+
238+
Raises
239+
-------
240+
ValueError
241+
"""
231242
raise ValueError('Cannot sample from Flat distribution')
232243

233244
def logp(self, value):
245+
"""
246+
Calculate log-probability of Flat distribution at specified value.
247+
248+
Parameters
249+
----------
250+
value : numeric
251+
Value for which log-probability is calculated.
252+
253+
Returns
254+
-------
255+
TensorVariable
256+
"""
234257
return tt.zeros_like(value)
235258

236259
def _repr_latex_(self, name=None, dist=None):
@@ -246,9 +269,32 @@ def __init__(self, *args, **kwargs):
246269
super(HalfFlat, self).__init__(defaults=('_default',), *args, **kwargs)
247270

248271
def random(self, point=None, size=None):
272+
"""Raises ValueError as it is not possible to sample from HalfFlat distribution
273+
274+
Parameters
275+
----------
276+
point : dict, optional
277+
size : int, optional
278+
279+
Raises
280+
-------
281+
ValueError
282+
"""
249283
raise ValueError('Cannot sample from HalfFlat distribution')
250284

251285
def logp(self, value):
286+
"""
287+
Calculate log-probability of Uniform distribution at specified value.
288+
289+
Parameters
290+
----------
291+
value : numeric
292+
Value for which log-probability is calculated.
293+
294+
Returns
295+
-------
296+
TensorVariable
297+
"""
252298
return bound(tt.zeros_like(value), value > 0)
253299

254300
def _repr_latex_(self, name=None, dist=None):
@@ -333,13 +379,41 @@ def __init__(self, mu=0, sd=None, tau=None, **kwargs):
333379
super(Normal, self).__init__(**kwargs)
334380

335381
def random(self, point=None, size=None):
382+
"""
383+
Draw random values from Normal distribution.
384+
385+
Parameters
386+
----------
387+
point : dict, optional
388+
Dict of variable values on which random values are to be
389+
conditioned (uses default point if not specified).
390+
size : int, optional
391+
Desired size of random sample (returns one sample if not
392+
specified).
393+
394+
Returns
395+
-------
396+
array
397+
"""
336398
mu, tau, _ = draw_values([self.mu, self.tau, self.sd],
337399
point=point, size=size)
338400
return generate_samples(stats.norm.rvs, loc=mu, scale=tau**-0.5,
339401
dist_shape=self.shape,
340402
size=size)
341403

342404
def logp(self, value):
405+
"""
406+
Calculate log-probability of Normal distribution at specified value.
407+
408+
Parameters
409+
----------
410+
value : numeric
411+
Value for which log-probability is calculated.
412+
413+
Returns
414+
-------
415+
TensorVariable
416+
"""
343417
sd = self.sd
344418
tau = self.tau
345419
mu = self.mu

0 commit comments

Comments
 (0)