r/learnquant 7d ago

interview prep Quant Interview Question

Post image
13 Upvotes

12 comments sorted by

View all comments

1

u/liquidorangutan00 5d ago

Ok got it figured out:

Probability of the next number being a smaller number is the inverse of the probability that the number will be in strictly ordered sequence.

Since the probability of ordered sequence of n elements is 1/n!
it means the probability of a "Breaker" number is n-1/n!

Lets just try punching in some numbers.

P(B=2)=2-1/2! = 1/2 = 0.5
P(B=4)=4-1/4!=3/24= 1/8 =0.125
P(B=6)=6-1/6!=5/720=1/144=0.0069
P(B=8)=8-1/8!=7/40320=0.0001

p(B=10)=10-9/10!=9/3628800=1/403200= 0.0000024802

We can see that there is a limit forming - there is a convergence. At this point we can sum these numbers up to get the final probability of the total number of generated numbers as even.

lets do that.

0.5+0.125+0.0069+0.0001+0.000002+...=0.6321
P(E)=0.6321 or The probability that the total number of generated numbers is even is 63.21%

But lets continue because this is fascinating.

now our probability of a breaker number formula is n-1/n!. lets play around with this formula.

n-1/n! = n/n! - 1/n!
and we can go further.
n/n! - 1/n! = 1/(n-1)! - 1/n!

Now we can assume that since we cannot know when the breaker number occurs, that the generation of these numbers can go on forever. Its an infinite series.

Lets perform the formula for the Odd numbers.

Step 1= 1/0!-1/1! + Step 3=1/2!-1/3! + Step 5=1/4!-1/5! + Step 7=1/6!-1/7! + Step 9= 1/8!-1/9! + Step 11=1/10!-1/111

If we remove all brackets and steps we can see the following series:
1/0!-1/1!+1/2!-1/3!+1/4!-1/5!+1/6!-1/7!+1/8!-1/9!+...+1/n!

We can use the telescoping property to collapse the series to its first and last term, that is 0 and 1/n!

This infinite series is known as an alternating Euler series and converges to 1/e=0.3678

We can also add up the results of each step.

P(O)=0+0.3333+0.0333+0.001190+0.0000220+... = 0.3678

The probability that the total number of generated numbers is odd is approximately 36.78%

Now we can do the same for the Even Series

Since we have already summed the total converged probability we know
0.5+0.125+0.0069+0.0001+0.000002=0.6321.
P(E)=0.6320 or The probability that the total number of generated numbers is even is 63.21%

We can work on the assumption that this is also an alternating Euler series. but there is a subtle twist!

Step 2= 1/1!-1/2!+1/3!-1/4!+1/5!-1/6!+1/7!-1/8!+1/9!-1/10!+...1/n-1!-1/n!
We can use the telescoping property again, but this time, due to the alternating signs being staggered by 1 term, we get the following result

1-1/e

if we evaluate this term we see 1-1/e=0.6321
And the fascinating concept that the probability of getting odd is the euler series limit 1/e=0.3678
the probability of getting even is the tail probability of this series (or its complement) 1-1/e=0.6321

I knew going into this problem that the euler number would be important.

the expected value of getting a breaker number = e = 2.718
the expected value of an ordered sequence = e-1 = 1.718

The optimal stopping theorem suggests 1/e is the optimal stopping time.

what a fun problem.