Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Yep - any distribution that is nonzero over the set of choices works, so over the reals, anything that is everywhere nonzero works.

For example, exp^{-x^2} with normalization factor is a simple choice.



Is there a complete explanation for this somewhere?

Asking for a friend, I obviously fully comprehend what you're talking about here.


Yeah, the solution is somewhat tricky. Here is the idea (this is somewhat sloppy, but gives the idea - if you're mathematically advanced all this can be made precise):

Suppose you have a way to pick a random number yourself, that has nonzero chance to pick any number. Suppose the person putting things in envelopes picks X < Y as their numbers. You too pick a random number, say T. Open an envelope. If that envelope is less than T, then switch. You will get the larger number more than half the time.

Here is why it works. You pick X or Y envelope with 50/50 odds. 3 cases:

1) Suppose you picked a T < X. If you opened X, then T < X, you don't switch, so you lose. If you opened Y, T < Y, you don't switch, you win. So if T < X you win half the time.

2) Suppose you picked a T with Y < T. Then no matter what you pick, T is not < your envelope, you will not switch, and again you win half the time. Nothing gained so far.

But, if you happened to pick X < T < Y, which happens with some nonzero chance, then analyze: if you open X, X < T, switch, you win. If you open Y, T < Y, you don't switch, you win. This case gives you more than 50/50 odds.

The technical details is it's minorly tricky to pick a real number out of an infinite set at random, with any number being a possible outcome. But the probability distributions above do the trick - basically any function you can draw that is everywhere positive, with the tails squeezing to zero fast enough (but never reaching it) will work.




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: