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

Skip to content

[Doc] Revise histogram features example (Closes #26604) #26606

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Aug 26, 2023
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