Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 19b1ce6

Browse filesBrowse files
jsdodgemeeseeksmachine
authored andcommitted
Backport PR #26606: [Doc] Revise histogram features example (Closes #26604)
1 parent 76b727d commit 19b1ce6
Copy full SHA for 19b1ce6

File tree

1 file changed

+8
-7
lines changed
Filter options

1 file changed

+8
-7
lines changed

‎galleries/examples/statistics/histogram_features.py

Copy file name to clipboardExpand all lines: galleries/examples/statistics/histogram_features.py
+8-7Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.