Skip to content

Commit f9f673f

Browse files
authored
[Doc] Revise histogram features example (Closes #26604) (#26606)
* [Doc] Revise histogram features example (Addresses Issue #26604) Remove reference to IQ scores and "Smarts" in figure; modify distribution parameters; update RNG syntax * Update histogram_features.py Wrap title string * Fix trailing whitespace * Restore RNG seed to 19680801
1 parent e5fd2d5 commit f9f673f

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

galleries/examples/statistics/histogram_features.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@
2020
import matplotlib.pyplot as plt
2121
import numpy as np
2222

23-
np.random.seed(19680801)
23+
rng = np.random.default_rng(19680801)
2424

2525
# example data
26-
mu = 100 # mean of distribution
27-
sigma = 15 # standard deviation of distribution
28-
x = mu + sigma * np.random.randn(437)
26+
mu = 106 # mean of distribution
27+
sigma = 17 # standard deviation of distribution
28+
x = rng.normal(loc=mu, scale=sigma, size=420)
2929

30-
num_bins = 50
30+
num_bins = 42
3131

3232
fig, ax = plt.subplots()
3333

@@ -38,9 +38,10 @@
3838
y = ((1 / (np.sqrt(2 * np.pi) * sigma)) *
3939
np.exp(-0.5 * (1 / sigma * (bins - mu))**2))
4040
ax.plot(bins, y, '--')
41-
ax.set_xlabel('Smarts')
41+
ax.set_xlabel('Value')
4242
ax.set_ylabel('Probability density')
43-
ax.set_title(r'Histogram of IQ: $\mu=100$, $\sigma=15$')
43+
ax.set_title('Histogram of normal distribution sample: '
44+
fr'$\mu={mu:.0f}$, $\sigma={sigma:.0f}$')
4445

4546
# Tweak spacing to prevent clipping of ylabel
4647
fig.tight_layout()

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy