I am trying to figure out and suspecting answer for this below question which was asked in a Quiz for which I chosed answer as option A. But I am unsure if this is correct or not. Please clarify if I am correct.
For a straight line with -1,000,000 to 1,000,000 marked and a person is initially standing at position 0. Person repeatedly tosses a fair coin that generates heads with probability 0.5, tails with probability 0.5. If a head is resulted, the person goes forward one step (current position 1). And if a tail is resulted, the person goes backward one step (current position - 1). The person does this for a million times.
What will be the outcomes in these below -
A) Person will be back at position 0 with 100% probability since heads and tails will perfectly cancel out.
B) Person will be between -10 and 10 with atleast 95% probability.
C) Person will be between -100 and 100 with atleast 95% probability.
D) Person will be between -2000 and 2000 with atleast 95% probability.
E) Person will be between -200,000 and 200,000 with atleast 95% probability.
CodePudding user response:
Based off by my own observations of a simple python script, I choose D.
#!/usr/bin/env python3.10
from random import choice
var = 0
def func():
var = 0
for i in range(0, 1000000):
if choice([1, -1]) == 1:
var = 1
else:
var -= 1
print(var)
for i in range(0, 100):
func()