-
Notifications
You must be signed in to change notification settings - Fork 322
Closed
Labels
Description
Some distributions will likely not work because of the check for parent dims being a superset of the child. For instance,
from pymc_marketing.prior import Prior, UnsupportedShapeError
p = Prior("Dirichlet", a=[1, 1, 1], dims="probs")
try:
Prior("Categorical", p=p, dims="trial")
except UnsupportedShapeError as e:
print(e)
This could be relaxed based on some logic from the rv_op. i.e. pm.Categorical.rv_op
has ndim_supp=0
and ndims_params=(1,)
or by parsing the numpy-like signature
Previous (incorrect) examples
EDIT: The following are wrong because categorical has signature of (p)->()
from pymc_marketing.prior import Prior
# Does work
p = Prior("Dirichlet", a=[1, 2, 3], dims="prob")
y = Prior("Categorical", p=p, dims=("trial", "prob"))
coords = {
"trial": [0, 1, 2, 3, 4],
"prob": ["A", "B", "C"]
}
samples = y.sample_prior(coords=coords)
The transpose doesn't work as well
# Doesn't works
z = Prior("Categorical", p=p, dims=("prob", "trial"))
try:
z.sample_prior(coords=coords)
except ValueError as e:
print(e)
# But would with other distributions
mu = Prior("Normal", dims="prob")
x = Prior("Normal", mu=mu, dims=("prob", "trial"))
samples = x.sample_prior(coords=coords)