Skip to content

Commit 47c334a

Browse files
author
Junpeng Lao
authored
implement random method for wishart (#2473)
For potential usage in SMC/ABC where we need random method to generate sample. Still not encourage to use.
1 parent 3232e16 commit 47c334a

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

pymc3/distributions/multivariate.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -650,10 +650,16 @@ def __init__(self, nu, V, *args, **kwargs):
650650
self.p = p = tt.as_tensor_variable(V.shape[0])
651651
self.V = V = tt.as_tensor_variable(V)
652652
self.mean = nu * V
653-
self.mode = tt.switch(1 * (nu >= p + 1),
653+
self.mode = tt.switch(tt.ge(nu, p + 1),
654654
(nu - p - 1) * V,
655655
np.nan)
656656

657+
def random(self, point=None, size=None):
658+
nu, V = draw_values([self.nu, self.V], point=point)
659+
size= 1 if size is None else size
660+
return generate_samples(stats.wishart.rvs, np.asscalar(nu), V,
661+
broadcast_shape=(size,))
662+
657663
def logp(self, X):
658664
nu = self.nu
659665
p = self.p

0 commit comments

Comments
 (0)