# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# %matplotlib inline
import matplotlib.pyplot as plt
import numpy as np

n_samples = 10000  #number of random samples to use
n_bins = 100       #number of bins for our histogram
sigma = 1.0        #rms width of the gaussian
mu = 0.0           #mean of the gaussian

x = np.random.normal(mu,sigma,n_samples)
print(x.min())
print(x.max())


def gaussian(x,mu,sigma):
    return 1./(2.0*np.pi*sigma**2)**0.5 * np.exp(-0.5*((x-mu)/sigma)**2)


fig = plt.figure(figsize=(7,7))
y_hist, x_hist, ignored = plt.hist(x, bins=n_bins, range=[-5,5], density=True)
xx = np.linspace(-5.0,5.0,1000)
plt.plot(xx,gaussian(xx,mu,sigma),color="red")
plt.ylim([0,0.5])
plt.xlim([-5,5])
plt.gca().set_aspect(20)
plt.xlabel('x')
plt.ylabel('y(x)')
plt.show()



StarcoderdataJupyterScriptsDedupFiltered