for N random normally distributed numbers
with mean = 0, stdev = 1:
Create a Python script that will count how many of these numbers fall between -1
and 1 and divide by the total quantity of N
You know that E(X) = 68.2%
Check that Mean(XN) -> E(X) as you rerun your script while increasing N
from IPython.display import Image
from IPython.core.display import HTML
Image(url= "normaldistribution.jpg", width=600)
import numpy as np
from numpy.random import randn
n = 100000
counter = 0
for i in randn(n):
if -1 < i and i < 1:
counter +=1
result = counter/n
print(result)
- by increasing the n, we are getting closer & closer to 68.2%