Coding Challenge 170: The Monty Hall Problem

  Рет қаралды 158,605

The Coding Train

The Coding Train

Күн бұрын

Пікірлер: 462
@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.
@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
@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 Жыл бұрын
This is also my favorite explanation, Bayes' formula or simply tabulating the outcomes does not yield intuitive understanding.
@antond131
@antond131 2 жыл бұрын
Coding train explaining The Monty Hall Problem better than both my math teachers and math youtubers. Impressive
@exoticlol
@exoticlol Жыл бұрын
This man is literally doing lectures that we enjoy.
@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.
@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)
@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.
@ordosolis
@ordosolis Жыл бұрын
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🥳
@DenisovichDev
@DenisovichDev 2 жыл бұрын
The intro was wonderful, Dan! Videos just keep getting better
@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
@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 Жыл бұрын
Why would you assume the host is forced to do anything?
@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.
@bokchoiman
@bokchoiman 2 жыл бұрын
I finally understand this problem.
@raoulkurjah7036
@raoulkurjah7036 2 жыл бұрын
I was so freaked out when he actually picked the door I was thinking in the 50 door example!
@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.
@firemonkey1015
@firemonkey1015 2 жыл бұрын
What an interesting video! Love this channel
@navibongo9354
@navibongo9354 Жыл бұрын
Glad i found your channel, loving ur vids (:
@TheCodingTrain
@TheCodingTrain Жыл бұрын
Welcome aboard!
@markboots_
@markboots_ 2 жыл бұрын
That was really scary! I did choose that door at 5:30 ! 😱😱😱
@nathanroed6924
@nathanroed6924 2 жыл бұрын
do you think that you could program a triangle filler on p5.js?
@jensBendig
@jensBendig 2 жыл бұрын
I understand it. But still my Intuition sees it differently.
@djtomoy
@djtomoy 4 ай бұрын
You should host a whimsical coding game show
@script5788
@script5788 2 жыл бұрын
You're awesome!!
@webdev723
@webdev723 2 жыл бұрын
Wow you're awesome dude
@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
@danieladegoke4910
@danieladegoke4910 2 жыл бұрын
Hi, is the scenario where the player picks the 2nd door(door with the price) and monty opens the first door and the user switches to the third door not different from the 2nd scenario you presented at the beginning on the table
@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?
@palingenesis
@palingenesis 2 жыл бұрын
Omg it’s so interesting ahah
@realcygnus
@realcygnus 2 жыл бұрын
Good one Dan ! 👍
@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!
@milkyroad9593
@milkyroad9593 2 жыл бұрын
Even it's demonstrably true I fail to understand it and I don't want to believe it
@MouseGoat
@MouseGoat 2 жыл бұрын
hmm some good physic training got a 42 on my stay rate, out of 100 Fell like i could do alot better was a lot more spot on on the later half than the first. :D
@alexmcd378
@alexmcd378 2 жыл бұрын
Reminds me of when I heard about the problem. I wasn't convinced by the logic, so I coded a simulation to generate the odds over a few thousand runs. Once I knew the switch was right, I dug in and finally understood the logic. I do wish I had had python to do it in instead of c++ :p
@zptro6316
@zptro6316 2 жыл бұрын
Here's the thing, goats are cool. I'd love to have 48, possibly 49 goats
@priyanshugoel3030
@priyanshugoel3030 2 жыл бұрын
What about picking door 2 revealing 1 instead of 3 won't that be another case in which the person loses.
@MrSephirothJenova
@MrSephirothJenova 2 жыл бұрын
No, it isnt. At least not in a significant way. You can only start on door 1, 2, or 3. You can then either switch or stay. In other words, there are only 3 significant starting states. This is because picking 2 and switching (regardless of the door shown) will always lose. What's important is one of the remaining doors after the goat is revealed ALWAYS contains the prize.
@TheCodingTrain
@TheCodingTrain 2 жыл бұрын
Thanks for helping clarify! I wish I had been a bit more clear in the video!
@kenhaley4
@kenhaley4 2 жыл бұрын
I would say it this way. Forget the door numbers. To begin with, you either pick the door with the prize (probability 1/3) or you pick a door with a goat (probability 2/3). Then the host reveals a door with a goat. Now, if you didn't pick the prize to begin with (probability 2/3--that didn't change), and you switch to the only remaining door, you win with a probabilty of 2/3. If you stay with your original door, the probability of winning is still only 1/3 - the same as it was to begin with.
@priyanshugoel3030
@priyanshugoel3030 2 жыл бұрын
If instead there are prizes with 0 goat ,1 goat and 2 goat what would be the expected no. of goats.
@zarblitz
@zarblitz 2 жыл бұрын
In this problem, there is no meaningful distinction between picking 2 then revealing 1, or picking 2 and revealing 3. Both are completely identical in terms of the problem space.
@DrIngo1980
@DrIngo1980 2 жыл бұрын
"I barely know CSS [...]" - trust me, nobody fully knows CSS. No. Body. 🙂
@qulmon32414
@qulmon32414 2 жыл бұрын
Algebra hs teacher told us this 🐐
@judgeomega
@judgeomega 2 жыл бұрын
if the host was a bad actor and only offered you a chance to switch if your initial guess was correct... then using the 'always switch' strategy will make you lose you 100% of the time. the assumptions and simplifications change things dramatically.
@louiswouters71
@louiswouters71 2 жыл бұрын
It's nor a simplification, that is how the game shiw was actually done and he mentions this at the start, the host always has to reveal a goat.
@judgeomega
@judgeomega 2 жыл бұрын
@@louiswouters71 iv seen the show before, and the host did NOT always give the player a chance to choose again. but you are right, if you assume specific things, then the numbers are right. that wasnt the issue, it was the assumptions made in the games simplification.
@louiswouters71
@louiswouters71 2 жыл бұрын
@@judgeomega Okay, didn't know that. In that case a lot of videos about this problem are wrong by not stating the simplification that a goat is always revealed
@kmbbmj5857
@kmbbmj5857 2 жыл бұрын
The point not included in any of the probability discussions is this is also a psychological exercise between Monty and guesser. Does he want me to switch or stay? Nor is it always door 1, 2, 3. It could also be "do you switch doors or go for the box Carol Merrel is now holding?" Or do you take the $1000 Monty pulls out of his pocket? And there are not always a good prize and two goats. Sometimes it's a new car behind one and a trip to Acapulco behind the other. Factor in all the other possibilities that may or may not happen or occasionally get chained together such as he offers a box and you pick the box over the door, but they need to stretch for time, so off you the change to switch the box for behind the curtain. Or maybe not.
@lebster_
@lebster_ 2 жыл бұрын
What’s the music at the start?
@lebster_
@lebster_ 2 жыл бұрын
Trip for Two Tv Game Show Background Music kzbin.info/www/bejne/hZnFnZd6hp6fbtk
@lebster_
@lebster_ 2 жыл бұрын
@Lebster Thanks
@marvndave
@marvndave Жыл бұрын
I don't buy this at all. What if my pick is door 2, but I just pretend to choose door 1 first, then switch to 2. My first and only choice was always door 2, I just pretended to pick door 1. This whole idea is absurd.
@klaus7443
@klaus7443 Жыл бұрын
You can test the problem with three cards, two 'Goat/switching wins', one 'Car/staying wins', by simply write down what you first picked.
@Araqius
@Araqius Жыл бұрын
Are you stupid? If the host open door 2, how the hell are you going to switch to door 2?
@Kiwipai
@Kiwipai Жыл бұрын
You can't truly do that, only the host that knows what's where can always reveal a door with a goat followed by letting your switch. In your scenario you say you pretend to pick one door then switch, but if you pretended to pick door only to have that one be opened wouldn't be possible. Same if actually pick door one and he opens door too. You don't need to get it yourself, but you can still accept it as the fact it is. It's an undisputable mathematical and empirical fact that your chances are 2/3 if you switch.
@dreibeinigesrentier7007
@dreibeinigesrentier7007 Жыл бұрын
Did you intentionally choose door 42 in the 50-door example? cause that would be a funny joke (I chose door 42 cause its the answer to everything ;) )
@sirthiccolas8168
@sirthiccolas8168 2 жыл бұрын
BOOOONNNNNEEEEE
@ninnusridhar
@ninnusridhar 2 жыл бұрын
It's not the math problem Dan. You just need to bone
@dawyer
@dawyer 8 ай бұрын
The situation is that "decisions without consequences" and "choices with practical benefits" are confused and regarded as having the same meaning. It has been clearly decided. If there are really two choices, shouldn't we get both things? In fact, the rule changes from one of three choices to one of two, misleading you into thinking that you have already chosen once, but in fact you cannot get any of the so-called choices at all. When you finally make the real choice, in order to prove how smart and knowledgeable you are, of course it should be counted as 2/3 when there are only two choices. This is a testament to the Goebbels effect. If scholars and the educational community do not correct the extension of Monty Hall's problem and still believe that 2/3 is correct, then what is the point of educational scholarship? ? It was ruined.
@anasouardini
@anasouardini Жыл бұрын
you forgot the possibility of 2-1-y-x. which makes it 50/50 chance.
@Araqius
@Araqius Жыл бұрын
Assume you stay with your first pick. If your first pick is Goat A, you get Goat A. If your first pick is Goat B, you get Goat B. If your first pick is the car you get the car. You only win 1 out of 3 games if you stay with your first pick.
@Araqius
@Araqius Жыл бұрын
"you forgot the possibility of 2-1-y-x. which makes it 50/50 chance." It's you who forget the important thing. If you pick D1 twice, the host will open D3 twice. If you pick D3 twice, the host will open D1 twice. If you pick D2 twice, the host will open D1 once, and D3 once.
@Araqius
@Araqius Жыл бұрын
"Araqius maybe but, if I pick 2 the reveled door would change my probability of winning, assuming that I don't know where is the winner object. it's just happened to be that when I pick other than the door with the winner object, the revealed door HAS to be the looser one, leaving me with only one option to switch to." Divide the doors into two groups. Group A: The door you pick - This group has one door. This group has 66% chance to be a goat. Group B: The doors you didn't pick - This group has two doors. This group will always have at least one goat. The chance this group has two goat is 33%. Now, the host remove a goat door ***from Group B***. Group B will now has one door and the chance this group has a goat is 33%. So the chance for this group to have a car is 66%.
@anasouardini
@anasouardini Жыл бұрын
@@Araqius so basically It's like picking two doors(66%) instead of one when I switch. hmm interesting.
@edvinbeqari7551
@edvinbeqari7551 Жыл бұрын
The solution as explained assumes a Monty game policy - meaning when you simulate this you are assigning the initial probability of the car to be equal for each door. How do you know? What if the prob is asymmetric? I am in the camp of 50/50 because you don't know how Monty is playing.
@RonaldABG
@RonaldABG Жыл бұрын
In general, I think the default assumption when you have no further information is that each option is equally likely, because even if you consider something like if they assign the car 80% of the time to some specific door and 10% of the time to each of the others, if you don't know which one is which is assigned each probability, then the three possibilities are equally probable for you: 80% 10% 10% 10% 80% 10% 10% 10% 80% When you take the average of them, you get that each door has 1/3 chance to have the car. From an asymmetric problem you ended in a symmetric one. You could also consider that each of the three scenarios has different probability to occur and add a new layer of uncertainty, but then the layer on top would be symmetrical again, and so on. Now, the solution of the Monty Hall game assumes that it is well defined that the host will always reveal a goat from the two doors that the player did not pick and offer the switch.
@ZZubZZero
@ZZubZZero Жыл бұрын
You do know how Monty is playing though. He always opens a door with a goat behind it. That's the definition of the problem.
@JarppaGuru
@JarppaGuru 2 жыл бұрын
6:08 i mean hello IM CORRECT DOOR IF GET THAT KIND OF CHANGE. behind scenes price is moved or added after its picked. it is same as 2 door pick one. i give you change switch. no i keep this. if im wrong door there would be change to switch they just open it. you select this door lets open. oooh missed!
@Hank254
@Hank254 2 жыл бұрын
Nope.
@toastyPredicament
@toastyPredicament 2 жыл бұрын
Hey can you make me into a cuter girl? I am deaf
@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!
@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/
@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!
@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!
@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.
@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.)
@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.
@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.
@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!
@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.
@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.
@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!
@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.
@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
@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?
@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.
@kerverse
@kerverse 2 жыл бұрын
I've Never Been this Early. Hi Dan!
@TheCodingTrain
@TheCodingTrain 2 жыл бұрын
Hi!
@IsaacPiera
@IsaacPiera 2 жыл бұрын
It's funny that number format applied to NaN gives NaN.00 ;)
@theuseraccountname
@theuseraccountname 2 жыл бұрын
Is there a way we can suggest a topic/video?
@RCTNT
@RCTNT 8 ай бұрын
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 :)
@caked3953
@caked3953 2 жыл бұрын
2 out of 3 people will call this good advice. The other ones not so much c:
@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.
@lrvogt1257
@lrvogt1257 22 сағат бұрын
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.
@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 Ай бұрын
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?
@coffee-is-power
@coffee-is-power Жыл бұрын
TLDR Yes, you should switch
@TheSourLemonz
@TheSourLemonz 2 жыл бұрын
great video dan
@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.
@mijimelon
@mijimelon 2 жыл бұрын
based theorem
@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.
@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!
@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
@xnick_uy
@xnick_uy 2 жыл бұрын
I'm mesmerized by the way you write the Y letter on the whiteboard 😄
@aydinjalalvandi6187
@aydinjalalvandi6187 2 жыл бұрын
You are a very big teacher. You are teaching people something more than just a goat or cat. Thanks
@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.
@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
@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!
@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
@Mobin92
@Mobin92 Жыл бұрын
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.
@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.
@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!
@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!!
@IDontModWTFz
@IDontModWTFz 2 жыл бұрын
I don't think you understand, I chose 1 and got the goat. I win already
@fridaaa0
@fridaaa0 2 жыл бұрын
This was so fun and exciting to watch, you're a great video host! What an awesome channel to come by
@SirArghPirate
@SirArghPirate 2 жыл бұрын
But, switching is only beneficial if you can be certain that the host knowingly picked an empty door, right? If he picked a door at random, then the initial 1/3 chance would persist?
@TheCodingTrain
@TheCodingTrain 2 жыл бұрын
This is correct! Though now that you’ve seen a door if it’s not the prize for that round your chance grows to 50%. If it is the prize it’s a 0% chance of course!
@SirArghPirate
@SirArghPirate 2 жыл бұрын
But would it increase to 50% if the host happened to just pick and reveal an empty door at random (not knowing that it was empty) or would it remain at 1/3?
@landsgevaer
@landsgevaer 2 жыл бұрын
@@SirArghPirate It would change to 50/50 even if the host was lucky a posteriori (even if the candidates didn't know that the host had no idea what he was picking).
@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.
@matiezequiel14
@matiezequiel14 2 жыл бұрын
Great explanation of the Bayes Theorem! I wish it existed when I had to take Statistics :D
@gloverelaxis
@gloverelaxis 2 жыл бұрын
Explaining the Monty Hall problem by coding it up is absolutely ingenious
@lucbloom
@lucbloom Жыл бұрын
The shortest explanation: - You have 1000 doors - Pick one - Open 998 wrong ones. … WANNA SWITCH??? [edit] ah yes you did that one.
@one_smol_duck
@one_smol_duck 2 жыл бұрын
wait i laughed so hard when you ran console.log('🐐'). like you just logged a _goat_ to the console 10/10 very good very great
@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!*
Coding Challenge 171: Wave Function Collapse
1:18:37
The Coding Train
Рет қаралды 545 М.
Coding Challenge 162: Self-Avoiding Walk
38:27
The Coding Train
Рет қаралды 153 М.
Офицер, я всё объясню
01:00
История одного вокалиста
Рет қаралды 3,7 МЛН
GIANT Gummy Worm Pt.6 #shorts
00:46
Mr DegrEE
Рет қаралды 93 МЛН
From Small To Giant Pop Corn #katebrush #funny #shorts
00:17
Kate Brush
Рет қаралды 70 МЛН
Coding Challenge 165: Slide Puzzle
26:53
The Coding Train
Рет қаралды 166 М.
Coding Challenge 169: Pi in the Sky Game
31:41
The Coding Train
Рет қаралды 87 М.
Someone improved my code by 40,832,277,770%
28:47
Stand-up Maths
Рет қаралды 2,5 МЛН
Coding Challenge 183: Paper Marbling Algorithm
32:10
The Coding Train
Рет қаралды 76 М.
Cracking Enigma in 2021 - Computerphile
21:20
Computerphile
Рет қаралды 2,5 МЛН
Game Theory Scene | 21(2008) | Now Playing
3:39
NOW PLAYING
Рет қаралды 1,9 МЛН
The Art of Code - Dylan Beattie
1:00:49
NDC Conferences
Рет қаралды 4,7 МЛН
Coding Challenge #89: Langton's Ant
20:58
The Coding Train
Рет қаралды 156 М.
Why Isn't Functional Programming the Norm? - Richard Feldman
46:09
Офицер, я всё объясню
01:00
История одного вокалиста
Рет қаралды 3,7 МЛН