**Question:** Consider Example 3.13, which refers to a miner trapped in a mine. Let N denote the total number of doors selected before the miner reaches safety. Also, let T_{i} denote the travel time corresponding to the ith choice, i ≥ 1. Again let X denote the time when the miner reaches safety.

- Give an identity that relates X to N and the T
_{i} - What is E[N]?
- What is E[T
_{N}]? - What is E[Σ T
_{i}|N = n]? - Using the preceding, what is E[X]?

**Analytical Solution**

- The first one is simply the sum of T
_{i}where the index over i from 1 to N - This section of the question is a little sneaky. Notice how the type of door that you take is dependent on the probability which is same for all the doors
- This means that the expected number of doors is simply the reciprocal of the probability
- I would suggest you to change the probability to not being same for all the doors, you will notice that the expected number of the doors is no longer equal to the reciprocal of any one of them

- Expected time taken for the N
^{th}to be exited- Since the N
^{th}door leads to the exit of the miner from entrapment, the time spent in the last step would always be the same and equal to 2 hours - This means that the expected time is also 2 hours

- Since the N
- Part 4 and Part 5 might seem deceptively similar. In the part 4, we are asked the expected time taken by the miner in entrapment given that we know the number of the doors taken whereas the part 5 asks for the expected time spent in entrapment without us knowing the actual number of the doors already visited
- From the question, we know that exiting steps takes 2 hours
- The other steps take 5 and 3 hours even though none of them lead to the exit
- The expected time needed to complete steps before getting to the exiting door would be (ExpectedPreTime)*(n-1)
- This would in-turn become 0.5(3+5)*(n-1) = 4(n-1)

- The total time is 4(n-1)+2

- The last one is an extrapolation from the result from part 4
- The answer would be E[4(n-1)+2] = 4E[n-1]+2 = 4*(3-1)+2 = 10

**Simulation Solution**

The simulations for this problem in one of my previous posts and here is the link. Just as a reference, I have included a new version of the code below.

from sys import stdout from mathematica.random_functions import RandomChoice, RandomReal from mathematica.lists import Transpose from mathematica.string_operations import StringPadLeft, StringPadRight print("Opening the text file") _file = open( 'your_file.txt', 'w') print("Initializing the loop and writing to the text file") print("_" * 106) _steps = 10000000 _subSteps = _steps // 100 for i in range(0, _steps): _n, _time = 0, 0 while True: _n += 1 _rand = RandomReal() if 0 <= _rand < 1 / 3: _time += 2 break elif 1 / 3 <= _rand < 2 / 3: _time += 3 elif 2 / 3 <= _rand <= 1: _time += 5 _file.write({_n, _time}.__str__() + '\n') if (i + 1) % _subSteps == 0: stdout.write("\r" + ("\r" + ("#" * (i // _subSteps + 1)).ljust(100)) + " " + str(i // _subSteps + 1) + " %") stdout.flush()

End of the post 🙂

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.