rethinkpriorities / squigglepy

Squiggle programming language for intuitive probabilistic estimation features in Python
MIT License
65 stars 8 forks source link

Add `.plot()` to `BaseDistribution` #4

Closed hibukki closed 1 year ago

hibukki commented 1 year ago

Instead of asking the user (forecaster) to explicitly create samples and use them for plotting, I suggest adding .plot() to each distribution.

My main argument for this being "correct" is that pandas DataFrame has a plot method.

Also, here's some code from the readme and how I imagine it changing if we had .plot():

Current code:

prior = sq.norm(1,5)
prior_samples = prior @ (10*K)
plt.hist(prior_samples, bins = 200)
plt.show()

My suggestion:

prior = sq.norm(1,5)
prior.plot() # optionally add `bins` and maybe other arguments

Do you agree this would be a good idea or do you have some pushback maybe?

peterhurford commented 1 year ago

I think I can make something like this happen!