<jupyter_start><jupyter_text>generate the random numbers using numpy<jupyter_code>x = np.random.normal(mu,sigma,n_samples)
print(x.min())
print(x.max())<jupyter_output>-4.11832448872537
3.70618721197358<jupyter_text>define a function to plot a gaussian<jupyter_code>def gaussian(x,mu,sigma):
    return 1./(2.0*np.pi*sigma**2)**0.5 * np.exp(-0.5*((x-mu)/sigma)**2)<jupyter_output><empty_output><jupyter_text>Create a histogram of the data<jupyter_code>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()<jupyter_output><empty_output><jupyter_text>Monte carlo Integration  Perform a simple Monte Carlo integration to compute Pi  Set some parameters of the integration<jupyter_code>%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
n = 10000 #number of samples for the integration<jupyter_output><empty_output><jupyter_text>Make some uniformly sampled vaiables [-1,1]<jupyter_code>x = np.random.uniform(-1,1,n)
y = np.random.uniform(-1,1,n)<jupyter_output><empty_output><jupyter_text>Find the number of samples within the unit circle<jupyter_code>ir = np.where((x**2 + y**2)<1.0 )[0]
ur = np.where((x**2 + y**2)>=1.0 )[0]<jupyter_output><empty_output><jupyter_text>plot the samples and the circle<jupyter_code>fig = plt.figure(figsize=(7,7))
plt.xlim([-1.1,1.1])
plt.ylim([-1.1,1.1])
plt.plot(x[ir],y[ir],'.',color="blue")
plt.plot(x[ur],y[ur],'.',color="0.75")
theta = np.linspace(0,2*np.pi,1000)
xc = np.cos(theta)
yc = np.sin(theta)
plt.plot(xc,yc,color="green")

plt.xlabel('x')
plt.ylabel('y')
plt.show()<jupyter_output><empty_output><jupyter_text>report the result for Pi<jupyter_code>pi_approx = 4.0*len(ir)/float(n)

error_pi = (pi_approx-np.pi)/np.pi

print("Number of samples = ",n)
print("Approximate pi = ",pi_approx)
print("Error in approx = ",error_pi)<jupyter_output>Number of samples =  10000
Approximate pi =  3.1556
Error in approx =  0.00445867684156994
{'fraction_non_alphanumeric': 0.17994376757263356, 'fraction_numerical': 0.05998125585754452, 'mean_word_length': 7.243243243243243, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '277535', 'license': 'MIT', 'n_tokens_mistral': 961, 'n_tokens_neox': 890, 'n_words': 147, 'path': 'random_number_generator.ipynb', 'repo_name': 'jebravo1/random_number_generator', 'size': '2134'}