Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOC: pymc.CustomDist example does not work in the documentation #7654

Open
helios1014 opened this issue Jan 22, 2025 · 1 comment
Open

DOC: pymc.CustomDist example does not work in the documentation #7654

helios1014 opened this issue Jan 22, 2025 · 1 comment
Labels

Comments

@helios1014
Copy link

Issue with current documentation:

When trying to run the following example code from the PYMC.CustomDist documentation, I get the error message "Core implementation of CustomDist_custom_dist_rv{"()->()"} not implemented":

from typing import Optional, Tuple

import numpy as np
import pymc as pm
from pytensor.tensor import TensorVariable

def logp(value: TensorVariable, mu: TensorVariable) -> TensorVariable:
    return -(value - mu)**2

def random(
    mu: np.ndarray | float,
    rng: Optional[np.random.Generator] = None,
    size : Optional[Tuple[int]]=None,
) -> np.ndarray | float :
    return rng.normal(loc=mu, scale=1, size=size)

with pm.Model():
    mu = pm.Normal('mu', 0 , 1)
    pm.CustomDist(
        'custom_dist',
        mu,
        logp=logp,
        random=random,
        signature="()->()",
        observed=np.random.randn(100, 3),
        size=(100, 3),
    )
    prior = pm.sample_prior_predictive(10)

Idea or request for content:

I do not know enough about PYMC to determine if this is a bug, my leaving something out, or the code not being correctly written in the documentation. If it is a bug, I will gladly report it as such. If if is not, please let me know what the correction is.

@ricardoV94
Copy link
Member

It doesn't fail on my machine, are you running the right version of PyMC? Try to update and run again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants