Specifying loc and scale on beta prior requires bounds, gives error

Many of the scipy specifications are a bit quirky.

Here is what I get in scipy:

loc, scale = 10,4
a = b = 1
x = np.linspace(scipy.stats.beta.ppf(0.01, a, b, loc=loc, scale=scale),
                scipy.stats.beta.ppf(0.99, a, b, loc=loc, scale=scale), 100)
rv = scipy.stats.beta(a, b, loc=loc, scale=scale)
fig, ax = plt.subplots(1, 1)
ax.plot(x, rv.pdf(x), 'k-', lw=2)
plt.show()

Note the x-axis.

scipy

And here are some prior predictive samples in pymc:

with pm.Model():
    loc, scale = 10,4
    b = pm.Beta('b', alpha=1, beta=1)
    shifted_b = pm.Deterministic('shifted_b', (scale * b) + loc)
    idata = pm.sample(10000, return_inferencedata=True)
    az.plot_trace(idata)
    plt.show()

b (untransformed) is on top, shifted_b is on the bottom.

1 Like