Exercise 5.1.10

Answers

import numpy as np 
N = 1000000 
a = np.random.randint(0,2,N) 
num_0 = np.sum(a<0.5) 
num_1 = np.sum(a>=0.5) 
avg = (num_0 * 0 + num_1 * 1)/N 
print(Averageofamillionrandom0-1samples:, avg) 
X = (avg-0.5)/2/np.sqrt(N) 
print(ThestandardizedvariableX=, X)
Average of a million random 0-1 samples:  0.500099
The standardized variable X =  4.9499999999980114e-08

User profile picture
2020-03-20 00:00
Comments