import matplotlib.pyplot as plt numargs = bernoulli.numargs [ pr ] = Replace with reasonable value * numargs rv = bernoulli(pr) # Display frozen pdf x = np.linspace(0, np.minimum(rv.dist.b, 3)) h = plt.plot(x, rv.pdf(x)) # Check accuracy of cdf and ppf prb = bernoulli.cdf(x, pr) h = plt.semilogy(np.abs(x - bernoulli.ppf(prb, pr)) + 1e-20) # Random number generation R = bernoulli.rvs(pr, size=100)