Visualize Distributions Before Building Model

Hello!

Before building a model in pymc3, sometimes I would like to view the prior I am assigning. Is there a one line way to do this?

So far, I’ve found that broad steps are:

  1. g = pm.Normal.dist(mu=2, sd=0.5) to get the distribution
  2. distribution = g.random(size=3000) to get a numpy array
  3. plt.hist(distribution) to visualize the result

Have I overlooked a simpler way to do this?

Hi,

You can simply add this line inside the model context:

prior_checks = pm.sample_prior_predictive(samples=500)

Now, you can access any RV dist in the prior_checks dict such as prior_checks['rv'].

1 Like