Skip to content

Instantly share code, notes, and snippets.

@ArnuldOnData
Last active March 8, 2021 04:12
Show Gist options
  • Select an option

  • Save ArnuldOnData/3d298ccb3f4ba5b94006bdc55b8ea3d3 to your computer and use it in GitHub Desktop.

Select an option

Save ArnuldOnData/3d298ccb3f4ba5b94006bdc55b8ea3d3 to your computer and use it in GitHub Desktop.
import matplotlib.pyplot as plt
import numpy as np
# Fixing random state for reproducibility
# -- Change next line of code --
# np.random.seed(19680801)
r = np.random.default_rng(seed=19680801)
N_points = 100000
n_bins = 20
# Generate a normal distribution, center at x=0 and y=5
# -- Change the next 2 lines of code --
#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)
# We can set the number of bins with the `bins` kwarg
axs[0].hist(x, bins=n_bins)
axs[1].hist(y, bins=n_bins)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment