Skip to content

Distribution variable API difficult to use for basic debugging: logp, logcdf, random samples, ppf #5798

@JonAnCla

Description

@JonAnCla

Description of your problem

This is more of a proposal - please let me know if this would be better put elsewhere.

One thing I often want to do while experimenting with or debugging models is to individually explore the RVs I'm using, but I find this difficult with the current API.

Maybe I'm missing something in the docs, but I find the current API awkward if I then want to: evaluate or plot pdf/cdf/ppf or draw RVs. I find it really helpful to do this especially for distributions where pymc (very usefully) provides parameterisations that are not provided by e.g. scipy (e.g. Beta has mu and sigma parameters). If I can't "see" what pymc is doing with my basic priors then I either have to find the formulae to convert the parameterisation into scipy-compatible parameters, or resort to trial and error (the horror!).

Currently you have to do things like this:

# generate 1000 samples of Bernoulli RV
pymc.Bernoulli.dist(p = 0.04, shape = [1000]).eval()  

# evaluate PDF of Binomial RV over interval 0-1000
pymc.logp(pymc.Binomial.dist(p = 0.04, n=1000), numpy.arange(0, 1000)).eval()  

# I'm not sure of any way to evaluate PPF but maybe I'm missing it?

Is e.g. pymc.Continuous.dist(...) wrapping basic scipy distributions somewhere (I guess not), and if so could those be exposed in a more obvious way so that we can access the scipy API e.g. https://docs.scipy.org/doc/scipy/reference/generated/scipy.stats.rv_continuous.html

Alternatively, could a more straightforward API for rvs/pdf/cdf/ppf etc be provided?

See also: #5032

Thanks for the awesome library :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions