Coding Challenge 170: The Monty Hall Problem

  Рет қаралды 159,259

The Coding Train

The Coding Train

Күн бұрын

Пікірлер: 464
@zarblitz
@zarblitz 2 жыл бұрын
Here’s how I finally intuitively understood the problem. If your initial guess is correct, then switching loses. If your initial guess is wrong, then switching wins. What are the odds your initial guess is wrong? 2/3. That means when your initial guess is wrong, 2/3 times, switching wins. Switching means you win 2/3 times.
@TheCodingTrain
@TheCodingTrain 2 жыл бұрын
Oh this is so good!
@alpha_ceph
@alpha_ceph 2 жыл бұрын
Agreed. This „reverse“ approach makes it so intuitive. It’s not about choosing between the 2 remaining doors but your initial pick. You want to land on a goat at first in order to guarantee a win by switching and that probability is 2/3.
@Teslacoil33
@Teslacoil33 2 жыл бұрын
I find it also helps to imagine the same problem with 10 doors. 9 of which have goats, and one of which has a prize. If after selecting a door, the host removed 8 other doors containing goats, would you decide to change your door? You obviously would as clearly the odds of you picking the correct door initially are only 10%
@secard4202
@secard4202 2 жыл бұрын
The first pick is merely a "gate" to pass through to get to the final 50/50, and due to logic tables, switching is then the better pick.
@sammason2300
@sammason2300 2 жыл бұрын
My most succinct explanation is very similar and goes as follows: If your strategy is to not swap then you obviously have a 1/3 chance of choosing the prize. However, if your strategy is to swap then you want to initially choose a goat and so your chance of winning is 2/3. Hence swapping is a superior strategy. This explanation applies equally to n doors where the success probabilities are 1/n and (n-1)/n respectively
@Tentin.Quarantino
@Tentin.Quarantino 2 жыл бұрын
Everyone’s assuming you want the prize more than the goat.
@preacherofblood8892
@preacherofblood8892 2 жыл бұрын
My thought exactly, what can you do with a car if you live in the city, but a cute goat in your apartment would be awesome
@404errorpagenotfound.6
@404errorpagenotfound.6 2 жыл бұрын
I'm afraid this thread has taken a dark path.
@Tentin.Quarantino
@Tentin.Quarantino 2 жыл бұрын
@@404errorpagenotfound.6 definitely teetering on the edge.
@404errorpagenotfound.6
@404errorpagenotfound.6 2 жыл бұрын
@@Tentin.Quarantino just look at the user name of the other commenter here wanting to get a goat in his apartment...bruh.
@Tentin.Quarantino
@Tentin.Quarantino 2 жыл бұрын
@@404errorpagenotfound.6 hah I didn’t notice! So this thread might end up with us summoning Baphomet.
@priyanshusingh2454
@priyanshusingh2454 2 жыл бұрын
Just finished a hard day at work and it's weekend time so I set out to watch some recreational content but I have been watching this coding video for the past 30 minutes. There's something very positive about the vibes you exude which makes coding seem more fun than entertainment videos.
@TheCodingTrain
@TheCodingTrain 2 жыл бұрын
Thank you for this kind feedback!
@veggiet2009
@veggiet2009 2 жыл бұрын
I've watched tons of videos about this, but that explanation "Would you like 1 door, or 2 doors?" is the simplest description I've ever heard! That's awesome!
@philrod1
@philrod1 2 жыл бұрын
My favourite way of thinking about this is that you have a 1/3 chance of picking the winning door at the start. This means that there is a 2/3 chance that the prize behind one of the two other doors. Because the reveal must be a losing door from the two you didn't pick, that means the remaining unpicked door has the full 2/3 chance of winning.
@TheCodingTrain
@TheCodingTrain 2 жыл бұрын
This is such a concise and excellent explanation!
@fridaaa0
@fridaaa0 2 жыл бұрын
wow, this actually made it intuitively click for me. thanks
@000aleph
@000aleph 2 жыл бұрын
This is also my favorite explanation, Bayes' formula or simply tabulating the outcomes does not yield intuitive understanding.
@exoticlol
@exoticlol 2 жыл бұрын
This man is literally doing lectures that we enjoy.
@thatsnuts8935
@thatsnuts8935 2 жыл бұрын
I feel lucky i watched the twitch live behind the scenes! Dan is really doing a great job, also a very fun, patient and awesome teacher!
@antond131
@antond131 2 жыл бұрын
Coding train explaining The Monty Hall Problem better than both my math teachers and math youtubers. Impressive
@Sam-by3uk
@Sam-by3uk 10 ай бұрын
I love that you don't plan these out in detail before. It really let's us see your thought process as you code. You are such a gift to humanity.
@JonathanChute
@JonathanChute 2 жыл бұрын
To me the easiest way to intuitively get this is to dumb down the question to an extreme. Host: Pick one of the three doors You: This one. Host: Do you want to have both of the other doors instead? You: Umm... yes? Host: But what if I told you that you can have these two doors, but one of them is a goat. You: I already know that. There are three doors, only one has a prize, you are offering me two doors, I already know at least one is a goat. Host: No but seriously one of these two doors is a goat, do you want your one door or my two doors. You: I want your two doors. Host: You don't understand, one of these two doors are a goat... See **opens one of the doors to show a goat** You: I already knew one of the doors was a goat, this doesn't change anything. I'll take your two doors please.
@TheCodingTrain
@TheCodingTrain 2 жыл бұрын
love this!
@BinaryBolias
@BinaryBolias 2 жыл бұрын
When you switch, you either get one goat or two goats.
@TheCodingTrain
@TheCodingTrain 2 жыл бұрын
Welcome Survivor fans! Say hi! 👇Live demo: codingtrain.github.io/Monty-Hall/
@InsectInPixel
@InsectInPixel 2 жыл бұрын
As I’ve been watching this, I realize you’re telling a story. Then I thought how neat it would be to write a story about JavaScript/ECMAScript written in English. And as you progress through the story, you introduce JS concepts piece by piece and finally at the end of the story, most of it is in JS. If anyone could pull this off, it would be you, Dan.
@TheCodingTrain
@TheCodingTrain 2 жыл бұрын
I like this idea! Writing and working with a script is a big challenge for me but I'd love to try stuff like this! (I improvise and do multiple takes for these videos.)
@beantown_billy2405
@beantown_billy2405 2 жыл бұрын
I've always struggled about the intuition behind this, and at 5:08 I finally got it!
@TheCodingTrain
@TheCodingTrain 2 жыл бұрын
Yay! this makes me so happy!
@idanmenaged6337
@idanmenaged6337 2 жыл бұрын
you’ve just made a better and more coherent argument for switching then pretty much anyone i talked to. i never really got why so many people thought that and u just solved a years old question for me in a few seconds. you’re pretty good at this
@TheCodingTrain
@TheCodingTrain 2 жыл бұрын
Glad to hear this thank you!
@proloycodes
@proloycodes 2 жыл бұрын
same!
@aydinjalalvandi6187
@aydinjalalvandi6187 2 жыл бұрын
You are a very big teacher. You are teaching people something more than just a goat or cat. Thanks
@kenhaley4
@kenhaley4 2 жыл бұрын
This was great. 😀 I remember when the problem first appeared in Parade magazine back in 1990, and reading the flood of responses, many claiming vehemently that Marilyn was wrong. But she refuted them all, and I remember the 100-door example she used to demonstrate her point. Fun problem.
@gloverelaxis
@gloverelaxis 2 жыл бұрын
Explaining the Monty Hall problem by coding it up is absolutely ingenious
@avananana
@avananana 2 жыл бұрын
I kinda got an intuitive sense for this by just thinking that if you always switch then you only lose if you guess the right door. There's a 1/3 chance you guess right, so you lose 1/3 of the time, which is equivalent to winning 2/3s of the time. Now that's the maths, but we all know that getting a goat would be a pretty cool prize so chances of winning at this game are 100%.
@TheCodingTrain
@TheCodingTrain 2 жыл бұрын
Agreed with all sentiments!
@zwampel4269
@zwampel4269 2 жыл бұрын
Omg you finally helped me understand the problem! I've watched so many videos before but I always gave up because it didn't make sense to me but now it does!!
@SimonTiger
@SimonTiger 2 жыл бұрын
Many people seem to be wondering, when he listed out all the possible scenarios, there were two scenarios in the case the person picks 2. This is true, this could have been explained more clearly. But it doesn't affect the final result because the initial chance you'll pick 2 in the first place is still 1 in 3. So it's more like the four possibilities are like this: - Pick 1 (1/3 probability) - Reveal 3 (1/3 probability) - Pick 2 (1/3 probability) - Reveal 1 (1/6 probability) - Reveal 3 (1/6 probability) - Pick 3 (1/3 probability) - Reveal 1 (1/3 probability) So it's like there are still three scenarios, but one of them has two "sub-scenarios", if you get what I mean.
@TheCodingTrain
@TheCodingTrain 2 жыл бұрын
Thank you Simon for this excellent clarification!
@landsgevaer
@landsgevaer 2 жыл бұрын
To complicate things, if the host did not know which door had the car but still decided to open one and that luckily turned out not to contain the car, then the two options do count (there are six equally likely options, two of which are excluded because of the info that the host didn't pick the car) and the chances have become 50/50, so then it doesn't matter whether you switch or not... So you need to be careful when phrasing the scenario.
@RCTNT
@RCTNT 10 ай бұрын
I just came in cold to your channel and completely by chance. Watched the whole thing. LOVED IT. You have a gift for teaching, what a stunning video. Gonna have to check out your body of work now, and I'm so glad to have found you! Nice one :)
@deatho0ne587
@deatho0ne587 2 жыл бұрын
You did a better job of explaining Bayes Therom in about 20 seconds than my college professor for stats did over 3 days. To be fair they were talking about other things that are a bit more complex also in terms of probability, but I get it now.
@onarandomnote25
@onarandomnote25 2 жыл бұрын
I love your work, I only just discovered your content a week ago and you're already my favourite content creator now... out of all the stats classes, lectures and breakdowns seeing you explain the Monty Hall problem succinctly while getting slightly distracted in 7 minutes while still holding audience focus is amazing.
@TheCodingTrain
@TheCodingTrain 2 жыл бұрын
Glad you enjoy it!
@DIProgan
@DIProgan 2 жыл бұрын
I actually coded this too once and halfway through doing it I finally understood the math because of the code!
@fredrik3685
@fredrik3685 Жыл бұрын
Take an extreme example. 1000 doors 1. You choose one door 2. The host opens 998 of the 999 remaining doors with a goat behind each. 3. Would you stick to your door or switch?
@shaileshrana7165
@shaileshrana7165 2 жыл бұрын
A very intuitive explanation: If you pick the wrong door initially, you always win by switching. Think about it. As picking the wrong door is more likely, you should always switch.
@RahulGuha-lq8bo
@RahulGuha-lq8bo 2 жыл бұрын
i started javascript a few days ago and found this channel and oh my its a jewel
@DanKaschel
@DanKaschel 2 жыл бұрын
Careful, much of this is p5.js and wouldn't work outside this environment, and it might not be obvious which parts are which. Also he tends to use a pretty old style (e.g. using a lot of for loops and complex global states); fine for learning, but not if you wanted to do it professionally. Other than that it really is a great channel.
@Sleepiwan
@Sleepiwan 2 жыл бұрын
Love it! I want to add for the viewers that the increased chances of winning by switching is due to the rule that the host never reveals the prize, something that is easily lost when explaining the problem to people and i think that not understanding that is what creates the counterintuitiveness that we feel when initially presented with the problem. If the host can reveal the prize aswell as the goat, the probability formula instead gives us 1/3 which is more in line of what most people find intuitive when not being explicitly told that the host may never reveal the prize.
@marcrindermann9482
@marcrindermann9482 2 жыл бұрын
4:50 I've known the Monty-Hall problem for many years and I've known the solution for just as long. But only now, seeing that you get two doors instead of only one when you switch do I truly understand the solution.
@fridaaa0
@fridaaa0 2 жыл бұрын
This was so fun and exciting to watch, you're a great video host! What an awesome channel to come by
@Mobin92
@Mobin92 2 жыл бұрын
The most intuitive explanation for me is that the host does not open the door at random. So he ALWAYS removes a losing door... which increases the chance for you to win, if you play the "new" game.
@RicoGalassi
@RicoGalassi 2 жыл бұрын
My god. I've been writing html and css for a long while now and I can tell you, 90% of the time, I need to look up how to center things in a div hahah
@kForto20
@kForto20 2 жыл бұрын
In pickDoor() i has to be random and not be called in a loop by incrementing it. If it stays like this you always know where the train is after a goat is revealed
@loic883
@loic883 2 жыл бұрын
it's more like if you pick door 1 : 1/3 of the time it will be a guaranteed win (if it spawns at door 2)
@kForto20
@kForto20 2 жыл бұрын
No I mean by the way the code is written you know have extra information. For example if you pick door 1 and door 3 is revealed you know 100% that the prize is behind door 2. That's because the code then checks the first door you didn't pick - in this case door 2.
@Willd2p2
@Willd2p2 2 жыл бұрын
@@kForto20 When choosing which door to reveal he puts all the possible options into an array and chooses at random from that array. In fact at 26:41 this exact scenario occurs and directly contradicts your claim - he picks door 1, door 3 gets revealed, he switches, and he loses.
@ordosolis
@ordosolis 2 жыл бұрын
I'm so glad I've come across this youtube channel, I was about to give up Learning 😩 Thank goodness for your videos, they are so engaging and well explained🥳
@pritamdavis
@pritamdavis 2 жыл бұрын
I guess the catch "host has to show the door in which prize is not there" changes the odds.
@louiswouters71
@louiswouters71 2 жыл бұрын
Correct, otherwise it would be 50-50
@pritamdavis
@pritamdavis 2 жыл бұрын
@@louiswouters71 yes
@xnick_uy
@xnick_uy 2 жыл бұрын
I'm mesmerized by the way you write the Y letter on the whiteboard 😄
@MenilekAlemseged
@MenilekAlemseged Жыл бұрын
Man is literally the ideal teacher ever!
@CodingAdventures
@CodingAdventures 2 жыл бұрын
Wow Dan! Congrats for a new episode and also for extending your great coding channel to twitch!
@TheCodingTrain
@TheCodingTrain 2 жыл бұрын
Thank you! I know I owe you a million replies on various messages I am so behind and disorganized thank you for your patience!!
@CodingAdventures
@CodingAdventures 2 жыл бұрын
​@@TheCodingTrain Thanks! And no worries at all! Please continue your great work of spreading the joy of coding to people around the world! CodingTrain is now one of the most influential coding channels on Internet! Well deserved.
@Gryf_
@Gryf_ Жыл бұрын
Damn I used to think I was very dumb for not getting it without having to make drawings, then I find people in the comment session full of themselves explaining why this is wrong and it is 50-50. I feel better about myself now.
@veggiet2009
@veggiet2009 2 жыл бұрын
7:27 I remember a few contestants on the original Let's make a deal that asked if they could go home with the "dummy" prize
@zerobyte802
@zerobyte802 2 жыл бұрын
Interestingly, if you randomly stay/switch, you win 50% of the time. (I learned this after programming it to win an argument over this) The reason is that half of the time, you win 1/3 and the other half of the time, you win 2/3. That’s an avg of 3/6 Also: It takes around 1m runs to have the percentage converge at 3 digits of accuracy.
@Hank254
@Hank254 2 жыл бұрын
That is correct! The reason is the probability of the doors is one thing, the probability of the contestant winning the car is another. Most people have no clue about that.
@RonaldABG
@RonaldABG 2 жыл бұрын
This is true for any problem. If you have "n" options with only one correct and you randomly select one of them (with 1/n chance to pick each), your chances to get the correct one will necessarily be 1/n, regardless of the probabilities of each one. Suppose the probabilities of the options were p1, p2, ..., pn. They must sum 1 because the total probabilities are always 1. Then the probabilities of selecting the correct are: (1/n) * p1 + (1/n) * p2 + ... + (1/n) * pn = 1/n * (p1 + p2 + ... + pn) = 1/n * 1 = 1/n
@gJonii
@gJonii 2 жыл бұрын
​@@RonaldABG As an addendum, this is why being really bad at predicting coin toss results or some such would be just as impressive as being really good at it. Being able to go either above or below 1/n is equally hard. Intuitively some may think that doing worse should be easier, but no, the ultimate bad is 1/n, going in either direction requires knowledge and skill.
@matiezequiel14
@matiezequiel14 2 жыл бұрын
Great explanation of the Bayes Theorem! I wish it existed when I had to take Statistics :D
@mylestrumbore5382
@mylestrumbore5382 2 жыл бұрын
Except that by revealing one door to be the goat and sticking with your origional choice means you're not choosing a 1 in 2 possibility of getting the prize. Your changes literally change because your population goes from 3 to 2. Your old odds no longer apply.
@DanKaschel
@DanKaschel 2 жыл бұрын
I think this is why so many people find this problem unintuitive. Let's play the same game with a twist. This time, there are 1000 doors instead of 3. You choose your door, and the host then eliminates 998 doors that are not the winner. There is just one solitary door left. Do you still stick with your original pick? If you're still unconvinced, try actually testing it with 10 doors where the host removes 8 wrong answers. The difference in probability will be much more apparent than the standard version.
@diceblue6817
@diceblue6817 2 жыл бұрын
4:50 you're the ONLY PERSON ON KZbin (i've seen them all) to actually CORRECTLY DESCRIBE THIS, you can even go one step more (it's a riddle, not a logic puzzle). BUT CONGRATS YOU ARE LITERALLY THE ONLY PERSON WHO MANAGED TO DO THIS (I've posted the same explanation about 50 times on other videos about it)
@TheOriginalJohnDoe
@TheOriginalJohnDoe 2 жыл бұрын
8:53 as a front-end dev, I smiled too hard for this one.
@danteUp
@danteUp 2 жыл бұрын
what a great video. i'm a information systems student and i learned so much! thx for the amazing work!
@simonraily330
@simonraily330 2 жыл бұрын
I really like this channel even considering that I working as a C embedded developer 😅
@DenisovichDev
@DenisovichDev 2 жыл бұрын
The intro was wonderful, Dan! Videos just keep getting better
@upanshulakhani6221
@upanshulakhani6221 2 жыл бұрын
Starting my day in the best way possible....with a coding challenge
@fredrik3685
@fredrik3685 2 жыл бұрын
If you first choose one door and then get the offer to change tho BOTH of the other two doors. Then I think most people would change. That's actually the exact offer you get in the show.
@klaus7443
@klaus7443 2 жыл бұрын
That is the worst explanation ever. It is not even the same math problem.
@fredrik3685
@fredrik3685 2 жыл бұрын
No it's exactly the same problem. The only thing that interferes in your thinking is that he is opening the door with a goat so you don't have to do it yourself.
@matthewmcgowan7288
@matthewmcgowan7288 2 жыл бұрын
The square you colored in was the one I picked and it freaked me out
@raoulkurjah7036
@raoulkurjah7036 2 жыл бұрын
I was so freaked out when he actually picked the door I was thinking in the 50 door example!
@nagesh007
@nagesh007 7 күн бұрын
Mind blowing , Awesome. Thanks 😍
@landsgevaer
@landsgevaer 2 жыл бұрын
Fun detail: As emphasized in the video, this is only true if the host *knew* where the car was! If the host didn't know but still decided to open one of the other doors (risky!), but as it turned out still picked a door without a car, then the chances have become 50/50.
@raiPKyt
@raiPKyt 2 жыл бұрын
No, knowing only helps to take this game longer..... It will still be 2/3 or n-1/n
@landsgevaer
@landsgevaer 2 жыл бұрын
@@raiPKyt Nope. If the host didn't know but opened a random other door, there are six equally probable possibilities (3 doors the player chose, times 2 doors the host chose). In 2 of these, the host opens a door with the car, so that is not avalid option: we know this once we've seen that the host shows a goat (a posteriori). Leaving 4 possibilities that are still equally likely. In 2 of these, the player picked the right door already, and in the 2 other the player should switch. 2 out of 4 either way, that is 50/50 chance. (Plenty of other comments that underline the same, and even in the video it is stressed at 2:14 that the host knows for this reason.)
@hughobyrne2588
@hughobyrne2588 2 жыл бұрын
Actually, the host's knowledge alone is not sufficient for the argument he makes for the conclusion he reaches. It could be that he knows where the car is, but before the game even started, he had flipped a coin to determine whether he'd open the leftmost unchosen door or the rightmost unchosen door. Knowledge that may or may not be held by another person does not, in and of itself, alter how you should calculate a probability from the information that's available to you to calculate it.
@MrSupahlovah
@MrSupahlovah 2 жыл бұрын
@@landsgevaer if you're going to use that argument, then in the case where the host always reveals a goat, in the case where you've already picked the prize, you have to count both cases where the host reveals a goat (both doors). Now we're down to a 1/2 instead of 2/3. It doesn't matter if the host knows what they're revealing, just what is revealed. Take the expanded case of 10 doors. You choose a door, and then 8 doors are revealed with goats. The host does not know what is behind the doors, but you're not aware of if they know or not. Do you switch?
@landsgevaer
@landsgevaer 2 жыл бұрын
@@MrSupahlovah If I am not aware whether they know, then I would switch, because there is a chance the he knew, and even if he didn't there is no harm in switching. My point is, however, that if I know that the host doesn't know (and he truly doesn't know, because maybe there are two hosts: one hiding the prize and another opening doors for me), then my chances of winning are 50% no matter whether I switch or not. If the host knew, then my original door has 10% chance and the remaining other door 90%, so then I benefit from switching. It certainly DOES matter whether the host knew.
@TheSourLemonz
@TheSourLemonz 2 жыл бұрын
great video dan
@ChristianAlmeidabr
@ChristianAlmeidabr 2 жыл бұрын
Excelent video to demonstrate how fast is developing using TDD! I went crazy with all those mistakes while “testing” if it works or not!! Aaahhhhh!! Do TDD!! DO TDD!!! Please!!! D-O T-D-D!!!!
@briumphbimbles
@briumphbimbles 2 жыл бұрын
The biggest problem with the Monty Hall problem is people forgetting that house knows where the prize is. Both in explanation and in application. If they do then its pretty obvious probabilistically if they don't then then it absolutely falls apart. It's a real non-revelation obfuscated by poor explanation.
@jensBendig
@jensBendig 2 жыл бұрын
I understand it. But still my Intuition sees it differently.
@Jacmac1
@Jacmac1 2 жыл бұрын
The best example of why it makes sense to switch is simply scale up the problem from 3 doors to 30 doors. If you pick a door #1 and 28 other doors are revealed leaving door #13, does it make sense to switch to #13? Of course!
@firemonkey1015
@firemonkey1015 2 жыл бұрын
What an interesting video! Love this channel
@alihms
@alihms 2 жыл бұрын
Rather than explaining, I've found the best way is to demonstrate it to them. From a deck or cards, take a joker card (representing the reward) and two other cards. Shuffle the 3 cards. Since you are the host, explain to them, you got to take a look at the cards after the shuffling (some people seemed to be confused by this!). Then, let them choose the card. You, knowing which card is the joker, select the non-joker card from the remaining two and expose it. Let them decide to switch or not, just like in the real game. It does not matter whether they win or lose. The key here is to REPEAT this as many times as needed. I've found that most people got it in less than 10 times of repeating this. It will 'click' to them. Just a word of caution. Some people were too smug to acknowledge they were wrong, even after it has clicked to them...
@TheCodingTrain
@TheCodingTrain 2 жыл бұрын
Great idea for a demo!
@ingiford175
@ingiford175 2 жыл бұрын
Now do it with the entire deck and one joker, and the problem becomes obvious.
@Popikawaii
@Popikawaii 2 жыл бұрын
After 5 times, you can just use the whole pack of cards. Revealing 50 cards and asking them if they want to switch should really hammer the point home.
@bokchoiman
@bokchoiman 2 жыл бұрын
I finally understand this problem.
@ous_537
@ous_537 2 жыл бұрын
best work , thanks so much hero
@Jhonegao
@Jhonegao 2 жыл бұрын
You are fantastic dude!
@asheep7797
@asheep7797 2 жыл бұрын
Ahh, so if you pick a goat, the host is FORCED to pick the other goat. This happens 2/3 of the time. The 3rd is a prize. 2/3 to switch.
@insignificantfool8592
@insignificantfool8592 2 жыл бұрын
Why would you assume the host is forced to do anything?
@BinaryBolias
@BinaryBolias 2 жыл бұрын
With more than three doors, and the possibility of multiple door reveals (with a choice of switching after each); regardless of the total amount of reveals, the optimal strategy is to switch at the last opportunity, but I'm not gonna elaborate on that. However... If there are five doors - with two correct and three incorrect - where two doors must be chosen, and both correct doors must be chosen to win: For the initial choice: - 2/20 chance - both door selections are correct. ( 2/5 first and 1/4 second ) - 12/20 chance - one correct door selection and one incorrect door selection. ( 6/20 first correct and second incorrect + 6/20 first incorrect and second correct ) - 6/20 chance - both doors are incorrect. ( 3/5 first and 2/4 second ) When a false door is revealed: Switching one door selection: - 2/20 chance - lose - both selections were already correct. - 6/20 chance - lose - one correct and one incorrect selection - the already correct door selection was switched. - 3/20 chance - lose - one correct and one incorrect selection - the incorrect selection was switched to be incorrect. - 3/20 chance - win - one correct and one incorrect selection - the incorrect selection was switched to be correct. - 6/20 chance - lose - both selections are incorrect. Switching both door selections: - 2/20 chance - lose - both selections were already correct. - 12/20 chance - lose - one correct and one incorrect selection. - 6/20 chance - win - both doors are incorrect. Summary: - 2/20 chance to win - switch no door. - 3/20 chance to win - switch one door. - 6/20 chance to win - switch both doors. Thus, I presume the optimal strategy would just be to switch as many doors as possible at only the final opportunity to do so. The video we really need, though, is one about how it works when there are at least three doors and at least two trinkets - where any number of trinkets may be hidden behind the same door - and where any number of doors, from one to the amount of trinkets, may be selected, and the final selection must include no door without trinket to win.
@tofonofo4606
@tofonofo4606 2 жыл бұрын
This was a lot of fun to watch. Cheers Dan 😊
@langlearnkorean8774
@langlearnkorean8774 2 жыл бұрын
I just read a wikipedia article about this problem 4 days ago after never hearing of it before..
@navibongo9354
@navibongo9354 Жыл бұрын
Glad i found your channel, loving ur vids (:
@TheCodingTrain
@TheCodingTrain Жыл бұрын
Welcome aboard!
@SembeiNorimaki
@SembeiNorimaki 2 жыл бұрын
It's funny that number format applied to NaN gives NaN.00 ;)
@michakolinski7281
@michakolinski7281 2 жыл бұрын
when we pick 2 we have 2 scenarios. 1st reveal 3, 2nd reveal 1. So we have 4 possibilities
@SimonTiger
@SimonTiger 2 жыл бұрын
We do, but the probability that we pick 2 is still 1 in 3. So it's more like we have 4 possibilities like this: - Pick 1 - Reveal 3 - Pick 2 - Reveal 1 - Reveal 3 - Pick 3 - Reveal 1 But each of the initial picks are still equally likely
@glenneric1
@glenneric1 2 жыл бұрын
It doesn't become blatantly obvious that you should switch until you see a thousand-door example with Monty opening up 998 doors out of a thousand, showing you 998 goats, while leaving your door and one other veeeeery conspicuous door closed.
@DeDodgingEse
@DeDodgingEse 2 жыл бұрын
This helped me probably the most. Thanks
@HKragh
@HKragh 2 жыл бұрын
Perfect way of making this go from unintuitive to obvious. Thanks!
@KtanKtanKtan
@KtanKtanKtan 2 жыл бұрын
Suddenly the choice becomes: stick with your door for a 1/1000 chance at winning, or pick the other door with a 1/2 chance of winning.
@glenneric1
@glenneric1 2 жыл бұрын
@@KtanKtanKtan The other door would be 999/1000
@flameofthephoenix8395
@flameofthephoenix8395 2 ай бұрын
Hm, the idea that this would help someone understand is confusing to me, if it didn't make sense before how does that small change allow people to understand it?
@jayjasespud
@jayjasespud 2 жыл бұрын
You have a 2/3 chance of picking incorrectly with your first choice. Because the host opens the other goat door, if you switch that 2/3 of the time you're switching onto the prize. It's about the chance of winning, not the ratio of goats to prizes, which I think is the confoundment.
@markboots_
@markboots_ 2 жыл бұрын
That was really scary! I did choose that door at 5:30 ! 😱😱😱
@script5788
@script5788 2 жыл бұрын
You're awesome!!
@kayakexcursions5570
@kayakexcursions5570 Жыл бұрын
Simple solution, your goal isnt to pick the correct door, you want to pick the wrong door. You have 2/3 chances of picking the wrong door then switch.
@vladig2835
@vladig2835 2 жыл бұрын
7:45 - You know it's about to be interesting when there is no canvas
@realcygnus
@realcygnus 2 жыл бұрын
Good one Dan ! 👍
@webdev723
@webdev723 2 жыл бұрын
Wow you're awesome dude
@BIGpony777
@BIGpony777 2 жыл бұрын
i did not believe you at first i seriously thought you were joking that it's a 50/50 shot
@jakubkurdziel2407
@jakubkurdziel2407 2 жыл бұрын
What a wonderful day
@kitpatient
@kitpatient 2 жыл бұрын
what a wonderful day
@clavesi
@clavesi 2 жыл бұрын
What a wonderful day
@kerverse
@kerverse 2 жыл бұрын
what a wondeful day
@faysalarab
@faysalarab 2 жыл бұрын
What a wonderful day
@LandinngGear
@LandinngGear 2 жыл бұрын
Like, I knew you were gonna say "Let's Make a Deal"... but I was really hoping after the train whistle you'd say "Code". Let's Make a Code
@TheCodingTrain
@TheCodingTrain 2 жыл бұрын
When I recorded this I was really trying to think of something like this to say! Oh well, maybe next time!
@coffee-is-power
@coffee-is-power Жыл бұрын
TLDR Yes, you should switch
@djtomoy
@djtomoy 6 ай бұрын
You should host a whimsical coding game show
@RupertBruce
@RupertBruce 2 жыл бұрын
The problem lies in the denominator of Bayes. The P(A) in the numerator yields 1/3...Why does P(B) not also yield 1/3? Because it is really P(B|C)!
@RupertBruce
@RupertBruce 2 жыл бұрын
In fact all terms are 'given C'
@danieltshiffman8212
@danieltshiffman8212 2 жыл бұрын
Ah this is a helpful clarification!
@tylim88
@tylim88 2 жыл бұрын
to understand this question, you simply need to realize that 1. after you make the decision, the probability won't change even if the pool change 2. the probability will change if you make a new decision on a new pool
@ranvirchoudhary929
@ranvirchoudhary929 2 жыл бұрын
Hey! i love your tutorials! they're so fun to watch! do you have any idea when you twitter bot series will be releasing? i'm very much waiting for it! :D
@TheCodingTrain
@TheCodingTrain 2 жыл бұрын
I haven't started recording it yet but hope to soon!
@palingenesis
@palingenesis 2 жыл бұрын
Omg it’s so interesting ahah
@15Nova22
@15Nova22 2 жыл бұрын
It being a 50:50 chance is actually reasonable, assuming the host has no information either. So define by the rules of the game it means that that approach is not doable but given the rule "After choosing, one random other door will be opened" This leaves you with "the door was the prize so you have no way of getting it again" and "that was a goat so one of the others is the prize". So the only reason this works is because of the information advantage the host has (even if you picked wrong he will never reveal the prize and you always have a chance)
@WS12658
@WS12658 2 жыл бұрын
Even if the host doesn't know either, it's still statistically better to switch. There's two outcomes: the host opens the door and the prize is revealed (in this case you can't win), or the host opens a door and the prize isn't revealed. In the case where the prize isn't revealed, it's still better to switch because there's still a 66.66% chance it's not behind the door you picked initially.
@louiswouters71
@louiswouters71 2 жыл бұрын
@@WS12658 no, because the chances of the host opening a goat are 100% when you picked a car(1/3 × 1). And 50% if you picked a goat (2/3 × 1/2). This means that in 1/3 of the games the host will reveal the car. In 1/3 of the games a goat is revealed while you choose the car. In 1/3 of the games a goat is revealed while you choose a goat. Once a goat is revealed, you know that scenario 1 is impossible, but the other 2 scenarios have equal chances, so 50-50
@lrvogt1257
@lrvogt1257 Ай бұрын
ABC=3/3 pick A=1/3 ... BC=2/3 goat B=0/3 ... C=2/3 Since the initial pick is probably wrong switching is probably right.
@JackDjTom6
@JackDjTom6 2 жыл бұрын
When Daniel drew the table at 4:25 he said there are only 3 ways this game can play out and the player wins 2/3 times when he always switches... But wouldn't there be a 4th way? Pick: 2 Reveal: 1 Switch? Yes WIn? No Then the player would have won 2/4 times when he always switches. And the same would apply to not switching. The player would win 2/4 times not switching. Am I wrong? Like I understand the math, but I didn't get that part ^^
@zarblitz
@zarblitz 2 жыл бұрын
The 4th option you present is functionally identical to the middle option in his table because the outcome of those two options will always be the same. There is no meaningful distinction between those states in this problem.
@kenhaley4
@kenhaley4 2 жыл бұрын
You're right--there are 4 scenarios, but they're not all equally likely. You have a 1/3 chance of picking door 2 (the prize door) to begin with, right? So then we can split that scenario into two--one where the host opens door 1 and the other when the host opens door 3. The probablities of those two cases must add up to 1/3 (as was already established); so they must be 1/6 each. The other two scenarios (where you picked door 1 or door 3) each have a probability of 1/3. As you said, "the player wins 2/4 times not switching". But that doesn't mean 2/4 = 50-50 because those 2 cases have a lower probability. Here's an analogy. I have a six-sided dice. One face has a 1, one face has a 2. Two faces have a 3, and two faces have a 4. Now, you roll the dice and you win if it comes up 1 or 2. Since there's only 4 possible outcomes (1, 2, 3 or 4) and you've covered two of them, you're chances of winning are 50-50, right? Obviously not. Your chance of winning is only 2/6 or 1/3.
@JackDjTom6
@JackDjTom6 2 жыл бұрын
@@kenhaley4 Ah ok thank you! That explanation is perfect :D
@dennisdistant
@dennisdistant 2 жыл бұрын
This is only true in JavaScript. In any other language it doesn't matter if you switch or not.
@TheCodingTrain
@TheCodingTrain 2 жыл бұрын
This made me laugh.
@Drog_o
@Drog_o 2 жыл бұрын
This man is crazy
@zer001
@zer001 2 жыл бұрын
Danke!
@TheCodingTrain
@TheCodingTrain 2 жыл бұрын
Thank you for the support!
@zer001
@zer001 2 жыл бұрын
@@TheCodingTrain thank you for this great Content.
@theneilpowers
@theneilpowers 2 жыл бұрын
This is quite the coincidence! I was making my own simulation of this at the same time. Admittedly I was only trying to optimize the simulation, but still odd.
@milkyroad9593
@milkyroad9593 2 жыл бұрын
Even it's demonstrably true I fail to understand it and I don't want to believe it
@gamefacierglitches
@gamefacierglitches 2 жыл бұрын
**Chooses door 2** Host: In door 1 is a cat. Would you like to switch to a door 3? Me: I'll switch to door 1. Host: But that's- Me: *DOOR 1 PLEASE!*
@greybeardmc
@greybeardmc 2 жыл бұрын
I wonder if anyone has actually gone back to the tapes of the old Let's Make a Deal, and found the actual win rate (for switch vs stay) of actual contestants?
@AleksanderFimreite
@AleksanderFimreite 2 жыл бұрын
It's easy to see from the available scenarios in this problem that switching leads to winning 2/3 times. But I felt like Dan did not give a very good description of which facts allows us to evaluate the probability change. Here is how I would explain it... Fact A: For 2/3 times, you will choose the wrong option at the start. (We know your first pick is most likely wrong) Fact B: Then the host reviels a known wrong option. (We know the prize still exists) Then you get to decide on whether to keep or switch. Having the knowledge of facts A and B, is what makes it possible to adjust the probability. We know your first pick is most likely wrong and we know the prize in one of the 2 remaining options. Saying that specific sentence, finally makes it sounds very logical. To me at least... Hope this helps someone understand probability a little better.
@TheCodingTrain
@TheCodingTrain 2 жыл бұрын
Thank you, this is a helpful explanation and I agree, I wish I had thought to put it this way too!
@stefenleung
@stefenleung 2 жыл бұрын
Now, it's time to up your game. How about 4 doors Monty Hall? by switching your chance become from 1/4 to 3/4*1/2 = 3/8, 50% boost. What if the host holding 2 doors and reveal one from his? by switching your chance become from 1/4 to 2/4, 100% boosting. 5 doors Monty Hall? by switching your chance become from 1/5 to 4/5*1/3=4/15, 33.33% boost. What if the host holding 2 doors and reveal one of his? by switching your chance become 1/5 to 2/5, 100% boosting again. What if the host holding up 3 doors? with that, your chance from 1/5 to 3/5*1/2 = 3/10, 50% boost. In fact, it doesnt matter how many doors there're, it's how many doors the host holding matters, for n doors he's holding, by switching your chance increase by n/n-1.
Coding Challenge 171: Wave Function Collapse
1:18:37
The Coding Train
Рет қаралды 554 М.
Coding Challenge 162: Self-Avoiding Walk
38:27
The Coding Train
Рет қаралды 154 М.
Hoodie gets wicked makeover! 😲
00:47
Justin Flom
Рет қаралды 136 МЛН
БУ, ИСПУГАЛСЯ?? #shorts
00:22
Паша Осадчий
Рет қаралды 2,9 МЛН
Кто круче, как думаешь?
00:44
МЯТНАЯ ФАНТА
Рет қаралды 6 МЛН
Coding Challenge 167: Ulam Spiral of Prime Numbers
24:13
The Coding Train
Рет қаралды 754 М.
How An Infinite Hotel Ran Out Of Room
6:07
Veritasium
Рет қаралды 30 МЛН
Fast Inverse Square Root - A Quake III Algorithm
20:08
Nemean
Рет қаралды 5 МЛН
The Monty Hall Problem | Brooklyn Nine-Nine
3:37
Brooklyn Nine-Nine
Рет қаралды 1,2 МЛН
Coding Challenge 169: Pi in the Sky Game
31:41
The Coding Train
Рет қаралды 87 М.
This equation will change how you see the world (the logistic map)
18:39
The Most Controversial Problem in Philosophy
10:19
Veritasium
Рет қаралды 4,7 МЛН
Coding Challenge 185: Unfolding Fractals
31:04
The Coding Train
Рет қаралды 44 М.
Coding Challenge 168: MandelBulb 3D Fractal
28:02
The Coding Train
Рет қаралды 375 М.
Hoodie gets wicked makeover! 😲
00:47
Justin Flom
Рет қаралды 136 МЛН