-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
add utility method to plot the pdf of a variable #5032
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
Comments
In the past I used The bigger question though is what to do with multidimensional RVs? |
In the first instance I think it makes sense to implement for univariate distributions. And override the method in distributions which are inherently multidimensional, potentially with a not implemented exception. At a later stage you could implement custom plot functions for bivariate distributions, for example. |
If you're looking for a place to put such a plotting function, that'd probably be |
Can't help but chime in and +1 this, I at least make plots like these just about every single time I use pymc |
Somewhat related, in Bambi we have a method to plot prior samples. https://bambinos.github.io/bambi/main/api_reference.html#bambi.models.Model.plot_priors |
I'm assuming we don't want to PyMC dependent upon arviz? In which case we'd have to just emulate the style? But it would be presumably be pretty easy by optionally doing import arviz as az
az.style.use("arviz-darkgrid") Overall I think we could make this pretty minimal. Users may want to compose their own complex and possibly multi-panel plots. |
We have a dependency on ArviZ and since ArviZ no longer depends on PyMC that's fine. But IMO any change of default style is something the user needs to do. I for example don't like the "arviz-darkgrid" style 😱 |
I agree. I prefer simpler styles more suitable for publication for example |
I like that proposal. We can raise an error on multidimensional variables. Additionally, a more flexible API is needed here. As any plotting function in the |
Yes. Was planning on full |
This should probably not me a method, because we don't really have class instances in V4 anymore, but something that accepts a RV. rv1 = pm.Normal.dist(0, 1)
with pm.Model() as m:
rv2 = pm.Normal("rv2", 0, 1)
pm.plot(rv1)
pm.plot(rv2) Both would yield the same. This has the advantage that you can plot the variables you defined in the model without having to rewrite with the .dist API In V4, rv1 and rv2 are identical for this purpose. |
Hi, wanted to add to this since I'd find this feature quite useful as well. Here's a colab demo notebook for proof of concept. |
Should this be an Arviz feature? Prior predictive is pretty fast anyway |
Not sure if you just mean moments/HDI should be part of Arviz or not? But as a defence of the idea of having distribution plotting in PyMC...
|
I think it's a slippery slope to re-introducing plots in PyMC xD |
Would these plot utilities need anything else other than draws? |
I am planning on adding the statistic/forest-plot stuff into ArviZ. I guess in
Having |
I see we would be plotting the pdf itself... yeah that is not arvizable :D |
By the way, |
Sorry I meant |
I am thinking similarly to @ricardoV94 -- I'd be hesitant to bring plotting back. However, it is something that I do quite a lot, especially:
So my heart says yes, but my head says no. What about something for pymc-experimental? |
In discussions in PyMC Labs, a client asked if there was a simple utility function to plot the pdf of a PyMC variable.
As a quick hack I came up with the following:
Continuous
which results in the following

Discrete
which results in this

So this issue is to see what people think about adding this functionality.
I've contributed example notebooks, but not to core PyMC code before, so it may be naive but... Maybe some more polished version could be added as methods of
pm.Continuous
andpm.Discrete
?Thoughts and feedback welcome.
The text was updated successfully, but these errors were encountered: