100 prisoners riddle: Can I demonstrate if Veritasium is right?

preview_player
Показать описание
Is the Veritasium correct about the 100 prisoners riddle?
There was a lot of theory, but do tests to back it up.
I wrote a simulation with code to prove once and for all whether Veritasium was right or wrong.
IT'S DATA TIME!

Veritasium Video:
The Riddle That Seems Impossible Even If You Know The Answer

Code:

Music
Kwon
Waveshaper
AM 1984
Рекомендации по теме
Комментарии
Автор

Got the video in the ad of veritesium's video, I knew he was right. Anyway appreciate your hardwork. Subscribed :)

shivamchouhan
Автор

There was nothing confusing about the original solution. And he did mathematically prove the percentages originally.

vishnupersaud
Автор

The Prisoners problem comes down to finding out whether there is a loop that is longer than half the population size (as mentioned at 8:25 in video). If there is, then some prisoners will not find their own number (failure), if there isn't, then the prisoners are guaranteed to all find their own number (success).
The main idea is that you do not need to generate the numbers in advance to determine the loops, you can generate them on the fly. Let's take the 10 prisoners as an example, and examine how a loop is determined. All numbers are random, so you can just as well start with prisoner 1. He first opens the box with number 1, with a chance of 1/10 to get 1. If that result is not 1, then he needs to open the box with that number.
But note that it does not really matter which specific number was in box 1, what is important is that the chance for the next box to contain 1 is 1/9. To test that, you just need to generate a random number from 1-9. The prisoner opens the next box, with a chance of 1/9 to get 1. If it is not 1, then the next box has chance 1/8 to contain 1, etc.
Suppose the prisoner draws 1 at this third occasion, then you know there is a loop of size 3. But you don't know anything yet about the remaining 7 numbers, so you repeat the process searching for the next loop, starting with 7 numbers this time. If after finding a loop, fewer than 5 boxes remain, you are certain the loops in there are all going to be shorter than 5, and the test succeeds. As soon as a loop gets longer than 5, the test fails.
The key insight is that it does not really matter which specific number comes up, it just matter what the probability is that it is the starting number of the loop. And that probability can be used to generate the random numbers on the fly.

I ran a program over night with 10, 000 tests with 1 billion prisoners, and the statistics came pretty close to the number mentioned in the video.

renedekker
Автор

For non-coders, you can replicate this game on a much smaller scale using playing cards.

Separate the deck into 4 suits and remove the Kings to keep the numbers even.

Spades = Prisoners
Diamonds = Slips of paper
Clubs = Boxes
Hearts = Prisoner Choices (when simulating random chance)

NoNameNoWhere
Автор

I wrote some python code that tested 'random' and 'follow your number' algorithms for 100 prisoners. My results agreed with Verulamium. I also wrote code that calculated the length of the loops and this worked out OK. I find this 'thought experiment' absolutely amazing.

gedtoon
Автор

This might be the first time you're hearing it, but wow, you guys are so alike—you could almost be brothers

kk
Автор

You ad on toms videos is very clever thanks for introducing me to your channel i know you will grow and surpass 1 mil in no time :) so much effort and love put in to your videos and it’s obvious 😊 keep it up

beatlezyt
Автор

If this strategy is done will less prisoners, the odds of success increase. If done with only 2 people, each person just opens the box with their own number on it and there's a 50% chance they both get it right.

jacobwansleeben
Автор

The effort for making this video deserves more views.

JiiaiOfficial
Автор

This is the first time youtube has put you in my recs. I loved Veritassium’s video. I’ve been thinking about it since I watched it a couple days ago (oh, that’s why I got the rec). I thought everything you said was an addition to what I learned from Veritassium. I’ll check out your channel. Subscribed!

michaelzumpano
Автор

this channel is going to explode very soon :) keep up the great work you

thomasnutter
Автор

It would have been nice if you had put an error bar to the percentage of success since you are doing a statistical sampling and the result can fluctuate around the mean value, where the amplitude of the fluctuations is proportional to the standard value (i.e. the sqrt of the variance) of the sampling. Not only it is standard good practice in statistics when sampling data, but also we would have seen that the theoretical value stands inside the confidence interval. Otherwise, great video.

gabiru
Автор

Good work with the intro!! Interesting video, keep up the

supl
Автор

Very good video for a channel this small keep it up🙌

giuliociccolo
Автор

If you're already accepting to take the leap to analysing just the length of the circuit. Just use something like the code below. The video is doing the same thing, but a lot more inefficient.

n = 10**9
H = 0
for k in range(int(n/2 + 1), n+1):
H = H + 1/k
print(1 - H)

fork
Автор

You explain even the most difficult concepts in a simple way.

OdessaHardaway-ez
Автор

Subscribed to your channel. You deserve more subs. I Appreciate your work

bunny
Автор

Made a spreadsheet for this to "prove" to myself, too. (Not sure demonstration is the same as proof, btw) The Savior Guard, Evil Guard, and the N-shift defense also appear to work, but the N-Shift without knowing you have a Savior guard can throw you from 100% to 31% survival.

DaleLombardo
Автор

HOW DID YOU KNOW I WAS WATCHING VERITASIUM, I'm honestly scared rn

Good video tough

thorsito
Автор

Good you made this video,
I tried to explain it to my family, and they where like, “nope” “don’t believe it” “prove it”
So…
Thanks
xD

nicolasherreros