Here's a math riddle inspired by a trading strategy.
🚶🏾♀️
Random Walk (3 steps)
Imagine a person is standing at the middle of a long staircase. Call their position zero.
They are going to move either up or down one step at a time.
They will take 3 steps. The direction of each step is random.
What is the probability the person crosses back through where they started (ie cross through zero)?
Solution
This is a binomial problem where n = 3
The total number of paths = = 8
With only 8 paths we can write them out:
25% of the paths back thru zero.
Pretty straightforward. One handy thing to note is the problem is symmetrical whether the first step is up or down so could have just focused on either the up moves or just the down moves and gotten to the same answer.
25%
🚶🏾♀️
Random Walk (5 steps)
Same question but now the person takes 5 steps, each in a random direction
What is the probability the person crosses back through where they started (ie cross through zero)?
Solution
n = 5
The total number of paths = = 32
We know from the earlier problem's symmetry that we can focus on just the 16 paths where the first step is "up".
You can probably sense the issue that’s emerging as the steps increase —> writing all the paths! With only 5 steps, it’s tedious to write out the 16 paths we will examine.
But it’s doable.
Yet we know it won’t be for long if the steps increase in later questions.
I asked ChatGPT how it would generate the paths and it gave me a clever answer:
The binary representation of each number is a distinct path!
The decimal to binary function in Excel —> DEC2BIN(number, places)
[warning: Excel can only convert a number into 10 bits which means the largest number you can represent is 512]
This is all good news. We can show all 16 paths without needing to figure them out manually.
But we still need to count how many paths cross zero.
Looking at path# 16, it’s clear it passes through 0. You moved up one step and then took 4 consecutive steps down.
Eyeballing we can see that steps #16-20 and #24 all cross zero.
So 6/16 or 37.5% of the time the random walk crosses through zero.
However, just as the binary representation saved us the need to generate each path manually, is there a way to see if the path crosses zero without needing to eyeball each route? Eyeballing isn’t going to work as steps increase.
If you like coming up with Excel formulas, then this will scratch the same itch.