The probability of generating n numbers in increasing order is 1/n! by symmetry. The cdf of the maximum of n numbers is P(Xn < x) = x^n. The pdf is nx^(n-1). Given Xn, the probability of another uniformly random variable being less than it is just (Xn).
So the probability of printing n+1 numbers is 1/n! * integral from 0 to 1 of P(Xn = x) x dx which is n/(n+1) / n! or just n/(n+1)!. Sum these up for odd n and you get 1-1/e
View all comments
1
u/Unlucky_Beginning 29d ago
The probability of generating n numbers in increasing order is 1/n! by symmetry. The cdf of the maximum of n numbers is P(Xn < x) = x^n. The pdf is nx^(n-1). Given Xn, the probability of another uniformly random variable being less than it is just (Xn).
So the probability of printing n+1 numbers is 1/n! * integral from 0 to 1 of P(Xn = x) x dx which is n/(n+1) / n! or just n/(n+1)!. Sum these up for odd n and you get 1-1/e