Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pymc/distributions/continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -2499,6 +2499,8 @@ def __call__(self, alpha, beta, size=None, **kwargs):

@classmethod
def rng_fn(cls, rng, alpha, beta, size) -> np.ndarray:
if size is None:
size = np.broadcast_shapes(alpha.shape, beta.shape)
return np.asarray(beta * rng.weibull(alpha, size=size))


Expand Down
8 changes: 8 additions & 0 deletions tests/distributions/test_continuous.py
Original file line number Diff line number Diff line change
Expand Up @@ -2369,6 +2369,14 @@ def seeded_weibul_rng_fn(self):
"check_rv_size",
]

def test_rng_different_shapes(self):
# See issue #7220
rng = np.random.default_rng(123)
alpha = np.abs(rng.normal(size=5))
beta = np.abs(rng.normal(size=(3, 1)))
draws = pm.draw(pm.Weibull.dist(alpha, beta), random_seed=rng)
assert len(np.unique(draws)) == draws.size


@pytest.mark.skipif(
condition=_polyagamma_not_installed,
Expand Down