In: Statistics and Probability
Perform a simulation experiment that will test the store owner’s hypothesis. Assume the following:
My suggestion is to run at least 1000 trials of the nine-minute journey of the robber.
Running the simulations, we get:
a. Average blocks walked = 6.126
Note that if he walks back a block, it is still counted. So, this is the steps he is not sleeping
b. Average distance from the store = 2.744
Note that this is the block distance from the store.
c. Probability that he is two blocks or less from the store = 0.4670
0d. The standard deviation of the probability s is 0.4989
The sample size n is 1000. Since the number of samples is large, we use the normal distribution.
A 95% confidence interval CI corresponds to a z-score of 1.96. So, the CI will be:
Note: Results will vary slightly if the simulation is done again.
Here is a python program for parts a to c:
from random import random
import numpy as np
cnt = 1000
smbwk = 0
smwlk = 0
awlk = []
for simulation in range(cnt):
x = 0
y = 0
bwk = 0
for i in range(9):
p = random()
if p <= 0.32:
pass
elif p <= 0.49:
x += 1
bwk += 1
elif p <= 0.66:
y += 1
bwk += 1
elif p <= 0.83:
x -= 1
bwk += 1
elif p <= 1.00:
y -= 1
bwk += 1
wlk = abs(x) + abs(y)
smbwk += bwk
smwlk += wlk
if wlk <= 2:
pwlk = 1
else:
pwlk = 0
awlk.append(pwlk)
print(smbwk/cnt)
print(smwlk/cnt)
print(np.mean(awlk))
print(np.std(awlk))