For each of the following distributions, plot its pdf in the given interval and a histogram based on 1000 samples. Use pdf(x, *args)
to compute the probability densities for the given array of x values, e.g.,norm.pdf(x, a, b). Use rvs(*args, n)
to sample n values, e.g. norm.rvs(a, b, n)
.
(a) Normal distribution: N(5,1.5)
. Plot interval: [0,10]
my current solution:
import numpy as np
import matplotlib.pyplot as plt
from scipy.stats import beta, expon, gamma, laplace, norm
x = norm.rvs(5,1.5,1000)
graph = plt.plot(x,norm.pdf(x,5,1.5))