Homepage › Solution manuals › Gilbert Strang › Linear Algebra and Learning from Data › Exercise 5.1.10
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(’Average␣of␣a␣million␣random␣0-1␣samples:␣’, avg) X = (avg-0.5)/2/np.sqrt(N) print(’The␣standardized␣variable␣X␣=␣’, X)
Average of a million random 0-1 samples: 0.500099 The standardized variable X = 4.9499999999980114e-08
2020-03-20 00:00