From fa8774651f07c0a488a02a3a867d6b847a56fb20 Mon Sep 17 00:00:00 2001 From: jsdodge <4602669+jsdodge@users.noreply.github.com> Date: Fri, 25 Aug 2023 22:48:15 -0700 Subject: [PATCH 1/4] [Doc] Revise histogram features example (Addresses Issue #26604) Remove reference to IQ scores and "Smarts" in figure; modify distribution parameters; update RNG syntax --- .../examples/statistics/histogram_features.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/galleries/examples/statistics/histogram_features.py b/galleries/examples/statistics/histogram_features.py index 354ef1a3b55e..3b20ec855304 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(19710717) # 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,9 @@ 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(fr'Histogram of normal distribution sample: $\mu={mu:.0f}$, $\sigma={sigma:.0f}$') # Tweak spacing to prevent clipping of ylabel fig.tight_layout() From e5e15045bdea5e1651e1ab6acc2a3b358afa3043 Mon Sep 17 00:00:00 2001 From: jsdodge <4602669+jsdodge@users.noreply.github.com> Date: Fri, 25 Aug 2023 23:12:07 -0700 Subject: [PATCH 2/4] Update histogram_features.py Wrap title string --- galleries/examples/statistics/histogram_features.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/galleries/examples/statistics/histogram_features.py b/galleries/examples/statistics/histogram_features.py index 3b20ec855304..17f4ff5d5f58 100644 --- a/galleries/examples/statistics/histogram_features.py +++ b/galleries/examples/statistics/histogram_features.py @@ -40,7 +40,8 @@ ax.plot(bins, y, '--') ax.set_xlabel('Value') ax.set_ylabel('Probability density') -ax.set_title(fr'Histogram of normal distribution sample: $\mu={mu:.0f}$, $\sigma={sigma:.0f}$') +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() From d9b4d5b4f561e8a2f78741b8ebb5d5c26f12c018 Mon Sep 17 00:00:00 2001 From: jsdodge <4602669+jsdodge@users.noreply.github.com> Date: Fri, 25 Aug 2023 23:26:28 -0700 Subject: [PATCH 3/4] Fix trailing whitespace --- galleries/examples/statistics/histogram_features.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/galleries/examples/statistics/histogram_features.py b/galleries/examples/statistics/histogram_features.py index 17f4ff5d5f58..590f99ff8ea7 100644 --- a/galleries/examples/statistics/histogram_features.py +++ b/galleries/examples/statistics/histogram_features.py @@ -40,7 +40,7 @@ ax.plot(bins, y, '--') ax.set_xlabel('Value') ax.set_ylabel('Probability density') -ax.set_title('Histogram of normal distribution sample: ' +ax.set_title('Histogram of normal distribution sample: ' fr'$\mu={mu:.0f}$, $\sigma={sigma:.0f}$') # Tweak spacing to prevent clipping of ylabel From 2819f5540baea4ea4a3694ccfcfd74163b6b9fed Mon Sep 17 00:00:00 2001 From: jsdodge <4602669+jsdodge@users.noreply.github.com> Date: Fri, 25 Aug 2023 23:53:13 -0700 Subject: [PATCH 4/4] Restore RNG seed to 19680801 --- galleries/examples/statistics/histogram_features.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/galleries/examples/statistics/histogram_features.py b/galleries/examples/statistics/histogram_features.py index 590f99ff8ea7..21f74fd1ac44 100644 --- a/galleries/examples/statistics/histogram_features.py +++ b/galleries/examples/statistics/histogram_features.py @@ -20,7 +20,7 @@ import matplotlib.pyplot as plt import numpy as np -rng = np.random.default_rng(19710717) +rng = np.random.default_rng(19680801) # example data mu = 106 # mean of distribution