From b437a71a54a02932d70bf174667474ff626954c0 Mon Sep 17 00:00:00 2001 From: rajpratyush Date: Mon, 15 Mar 2021 09:30:33 +0530 Subject: [PATCH 1/2] Updated Random Number Generation in Numpy --- examples/statistics/hist.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/statistics/hist.py b/examples/statistics/hist.py index 5fd409911c89..98f56428ac44 100644 --- a/examples/statistics/hist.py +++ b/examples/statistics/hist.py @@ -12,7 +12,7 @@ from matplotlib.ticker import PercentFormatter # Fixing random state for reproducibility -np.random.seed(19680801) +r = np.random.default_rng(seed=19680801) ############################################################################### @@ -27,8 +27,8 @@ n_bins = 20 # Generate a normal distribution, center at x=0 and y=5 -x = np.random.randn(N_points) -y = .4 * x + np.random.randn(100000) + 5 +x = r.standard_normal(N_points) +y = .4 * x + r.standard_normal(100000) + 5 fig, axs = plt.subplots(1, 2, sharey=True, tight_layout=True) From 0c8bcb39b5821eff2d7a110f06eaf97a70056135 Mon Sep 17 00:00:00 2001 From: rajpratyush Date: Mon, 15 Mar 2021 19:04:25 +0530 Subject: [PATCH 2/2] updated the variable name --- examples/statistics/hist.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/examples/statistics/hist.py b/examples/statistics/hist.py index 98f56428ac44..68277b52f183 100644 --- a/examples/statistics/hist.py +++ b/examples/statistics/hist.py @@ -12,7 +12,7 @@ from matplotlib.ticker import PercentFormatter # Fixing random state for reproducibility -r = np.random.default_rng(seed=19680801) +rng = np.random.default_rng(seed=19680801) ############################################################################### @@ -27,8 +27,8 @@ n_bins = 20 # Generate a normal distribution, center at x=0 and y=5 -x = r.standard_normal(N_points) -y = .4 * x + r.standard_normal(100000) + 5 +x = rng.standard_normal(N_points) +y = .4 * x + rng.standard_normal(100000) + 5 fig, axs = plt.subplots(1, 2, sharey=True, tight_layout=True)