Hi, I think I found an error in the code snippet in exercise 2 in Chapter 5.
In the book (page 225) it's given as:
rng = np.random.default_rng(10)
store = np.empty(10000)
for i in range(10000):
store[i] = np.sum(rng.choice(100, replace=True) == 4) >0
np.mean(store)
During each iteration, only one number is chosen instead of a full sample.
I think it should be corrected to:
rng = np.random.default_rng(10)
store = np.empty(10000)
for i in range(10000):
store[i] = np.sum(rng.choice(100, size=100, replace=True) == 4) >0
# as we would like to sample 100 observations at each attempt and check if 4 is among them
np.mean(store)
It gives 0.6362 which is the probability of the jth observation chosen when n goes infinity.
Hi, I think I found an error in the code snippet in exercise 2 in Chapter 5.
In the book (page 225) it's given as:
During each iteration, only one number is chosen instead of a full sample.
I think it should be corrected to:
It gives 0.6362 which is the probability of the jth observation chosen when n goes infinity.
BR Grzegorz