Skip to content

Commit 4817bc5

Browse files
committed
Add doc strings for random and logp class methods for mixture distribution
1 parent e2a97ea commit 4817bc5

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

pymc3/distributions/mixture.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -397,13 +397,42 @@ def infer_comp_dist_shapes(self, point=None):
397397
return comp_dist_shapes, broadcast_shape
398398

399399
def logp(self, value):
400+
"""
401+
Calculate log-probability of defined Mixture distribution at specified value.
402+
403+
Parameters
404+
----------
405+
value : numeric
406+
Value(s) for which log-probability is calculated. If the log probabilities for multiple
407+
values are desired the values must be provided in a numpy array or theano tensor
408+
409+
Returns
410+
-------
411+
TensorVariable
412+
"""
400413
w = self.w
401414

402415
return bound(logsumexp(tt.log(w) + self._comp_logp(value), axis=-1),
403416
w >= 0, w <= 1, tt.allclose(w.sum(axis=-1), 1),
404417
broadcast_conditions=False)
405418

406419
def random(self, point=None, size=None):
420+
"""
421+
Draw random values from defined Mixture distribution.
422+
423+
Parameters
424+
----------
425+
point : dict, optional
426+
Dict of variable values on which random values are to be
427+
conditioned (uses default point if not specified).
428+
size : int, optional
429+
Desired size of random sample (returns one sample if not
430+
specified).
431+
432+
Returns
433+
-------
434+
array
435+
"""
407436
# Convert size to tuple
408437
size = to_tuple(size)
409438
# Draw mixture weights and infer the comp_dists shapes

0 commit comments

Comments
 (0)