for i in range(0, N):
    samples[i] = np.random.exponential()
mu = np.mean(samples)
print('N = %d  ==> mu = %f' % (N, mu))
n, bins = np.histogram(samples, bins=int(np.sqrt(N)), density=True)
plt.step(bins[:-1], n, color=color, label='samples N = %d' % N)
xmax = max(bins)
plot_exponential_density(mu, xmax, color + '--', label=
    'estimated density N = %d' % N)
return xmax
xmax1 = sample_and_plot(100, 'r')
xmax2 = sample_and_plot(10000, 'b')
plot_exponential_density(1, max(xmax1, xmax2), 'k', 'true density')
plt.legend()
plt.show()
How can I plot maximum likelihood estimate in Python