Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions galleries/examples/statistics/histogram_features.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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()
Expand Down