diff --git a/galleries/examples/statistics/histogram_features.py b/galleries/examples/statistics/histogram_features.py index 354ef1a3b55e..21f74fd1ac44 100644 --- a/galleries/examples/statistics/histogram_features.py +++ b/galleries/examples/statistics/histogram_features.py @@ -20,14 +20,14 @@ import matplotlib.pyplot as plt import numpy as np -np.random.seed(19680801) +rng = np.random.default_rng(19680801) # example data -mu = 100 # mean of distribution -sigma = 15 # standard deviation of distribution -x = mu + sigma * np.random.randn(437) +mu = 106 # mean of distribution +sigma = 17 # standard deviation of distribution +x = rng.normal(loc=mu, scale=sigma, size=420) -num_bins = 50 +num_bins = 42 fig, ax = plt.subplots() @@ -38,9 +38,10 @@ y = ((1 / (np.sqrt(2 * np.pi) * sigma)) * np.exp(-0.5 * (1 / sigma * (bins - mu))**2)) ax.plot(bins, y, '--') -ax.set_xlabel('Smarts') +ax.set_xlabel('Value') ax.set_ylabel('Probability density') -ax.set_title(r'Histogram of IQ: $\mu=100$, $\sigma=15$') +ax.set_title('Histogram of normal distribution sample: ' + fr'$\mu={mu:.0f}$, $\sigma={sigma:.0f}$') # Tweak spacing to prevent clipping of ylabel fig.tight_layout()