Givrally

For that one guy in the comments.
(The 12V-2x6 connector hasn't burned down yet if you're wondering)

1 week ago | [YT] | 0

Givrally

Here's a simulation I wrote for my latest Youtube comment argument, about the Monty Hall problem.

Let's imagine you're participating in the Monty Hall game. You know the drill, pick a door, Monty reveals the goat, you switch to the other door. Everyone knows what's gonna happen, boring.
After picking your door, Monty yawns, prepares to open the other goat door, when suddenly a drunk audience member rushes on stage and opens a door at random ! Everyone gasps, as the door opens to reveal... a goat ! And on top of that, it was the door Monty wanted to open. Whew !
Now everything is going to proceed as normal... or is it ?

You see, the difference here is that the drunk guy had no idea which door had the car, or even which door you picked (no one was listening anyway), meaning this miraculous save only had a 1/3 chance of happening. Usually you'd benefit from the fact that Monty knows where the car is, but here, it doesn't work, even if the outcome is the same.
The 1/3 probability that this goat door held actually shifts equally to both other doors, and it's actually a 50% chance.
To prove it, let's try to compute the probability that the car is in the other door, given that the miracle happened. For that, we'll use Bayes' theorem.
Let's separate the case where the drunk guy has picked your door, since each door obviously has a 50% chance of having the car.
If the drunk guy picked one of the other doors, separate cases again : If the car is in your door, then no matter which one he picks, the miracle happens (100% chance of miracle given you have the car)
If the car is in the other doors, then there's a 50% chance the miracle happens (50% chance of miracle given the car is in the other doors).
Therefore, by separation of cases, the probability of the miracle happening is 1/3 times 100% plus 2/3 times 50%, which equals 2/3.
P(Car in other doors | Miracle) = P(Miracle | Car in other doors) * P(Car in other doors) / P(Miracle) = 50% times 2/3 divided by 2/3 = 50%. The math checks out !

But of course, we could have made a mistake, so we need to verify it numerically. That's what my code is for !
When simulating for a drunk guy, we check if the simulation is valid, i.e if the remaining doors contain both the car and your initial choice. If not, we reject that simulation. If it's correct, though, we check if the final choice (after switching) is the car. This can work with any number of doors, we assume Monty always opens all but two doors.
As you can see with 100 doors, there's only a tiny fraction of simulations left (it is a miracle after all), but in those, we do indeed see a 50% win rate !

The code, in case someone wants to fiddle with it : pastebin.com/Whz5YvXy
(It is, obviously, very quick and dirty, I must have broken at least a dozen different PEP8 rules)

9 months ago (edited) | [YT] | 5

Givrally

So apparently I have community posts now ? There's no way that should be happening, but sure, I'll take it.

Apparently youtube loves polls so here you go :

3 years ago | [YT] | 3