Consecutive Coin Flips - Numberphile
Вставка
- Опубліковано 29 вер 2024
- Thanks www.audible.com... (recommendations below)
This video features Dr James Grime.
More links & stuff in full description below ↓↓↓
More on coin flips: • How random is a coin t...
See the prime number video referenced at: • The Last Digit of Prim...
Support us on Patreon: / numberphile
NUMBERPHILE
Website: www.numberphile...
Numberphile on Facebook: / numberphile
Numberphile tweets: / numberphile
Subscribe: bit.ly/Numberph...
Numberphile is supported by the Mathematical Sciences Research Institute (MSRI): bit.ly/MSRINumb...
Videos by Brady Haran
Brady's videos subreddit: / bradyharan
Brady's latest videos across all channels: www.bradyharanb...
Sign up for (occasional) emails: eepurl.com/YdjL9
Numberphile T-Shirts: teespring.com/...
Other merchandise: store.dftba.co...
Books...
- K2: Life and Death on the World's Most Dangerous Mountain
- Dark Summit: The True Story of Everest's Most Controversial Season
- Everest 1953: The Epic Story of the First Ascent
- High Crimes: The Fate of Everest in an Age of Greed
- Into Thin Air
I've lost 400 thousand dollars to this scam now.
it cost that much to fire this weapon for 12 seconds.
What scam?
- Heavy
Who touched sasha?
Simo Vihinen you never had that much
it is a somewhat ill-defined problem. The search should restart after the first coin-flip, not the last - then all the overlaps get counted and it works for sequences of any length.
This reminds me of something I was talking about last night with a friend. We spoke of how birth control works %99.9 of the time. Which means 1 out of 1000 times it won't work. So I'm wondering what the average wait time for that 1 time out of 1000 occurrence is.
Are players playing entirely independent games? Because if you say that either condition wins, stops the game for both players, then a new game starts for both players, you get a different result with this example.
So we're betting, I take HH and you take HT, and if EITHER comes up, the game is over and resets with the next sequence being a new game for both players and sequences. In that condition, you get the following:
HT - win in 7, HT - 2, HH - 6, HH - 2, HH - 3, HH - 2, HT - 6, HH - 3, HT - 4, HT -2 , HH - 5, HT - 2, and HT - 6.
HT wins 7 times, HH wins 6.
The average waiting time for HT is 7+2+6+4+2+2+6 = 29. And 29/7 = 4.14
The average waiting time for HH is 6+2+3+2+3+5 = 21. And 21/6 = 3.5
Just like you couldn't count the overlapping HH's in the way you played it, here you can't count the HTs where the H is the second in an HH series (which knocks out 4 of the HTs). In this example, as a unified game, HH comes up slightly less often, but faster when it does.
Why would you mention the prime sequence? The coin toss effect happens because the described outcomes are not independent of prior tosses. Primes are independent of prior primes, are they not? Without knowing the distribution of primes how would this approach help?
that makes sense because you can't have a HT where a HH is
he's so cute and explains all understandable
135th! Man you guys are quick!
Colored sharpies and some dice I saw on a table, and no one is playing D&D. Oh well, maybe a future video ;)
i once a long time ago made a script calcing stuff like this. I one time got 32 time heads after eachother
I would not trust computers RNG
+Goodforthewin why not?
Why? The probability may be small, but it's not zero. He was just "lucky".
+abschussrampe I ran that script for a very long time and it flips waaaaay faster than you do irl, combine those with some luck. I think I have the stats logged somewhere. how many times of retrying it took
I got 32 heads in 979643625 tries (it only counted the tries not the every coin flipped example with 3: H H T is 1 count) wich still is lucky cause according to wolframalpha its a 1 in 4294967296 thing.
pre-video prediction: heads heads is less likely, because if you fail the second flip, you have to start over again. With heads tails failing the second flip means you already have the first heads toss in the bag, and now only need tails.
He explained the same thing in a different manner.... but I find your way of explaining it easier for understanding the concept.
Jarrod Tavares :)
Nailed it.
That's what i tought :D
thanks, that got me around my brainblock
9/11 confirmed by Dr James Grime
Jet fuel doesn't melt zinc pennies
Not unless if it's ON FIREEEE!
Zinc has one of the lowest melting points of all the metals at 420C. Jet fuel burns hotter than that
LOL 420
Unless you're a wizard, I'm pretty sure that u can't melt zinc with jet fuel at room temperature at sea level.
Man, whenever James is in a video i set the playback speed to .50 because hearing him talk like hes drunk is so amusing.
Try it yourself.
Lol
the confession at the end is priceless and actually makes the whole thing so adorable
yeah, i think so
No, the whole thing wasn't a lie. When you're dealing with probabilities, there is always the chance that abnormalities (outliers) will pop out, especially when you're dealing with relatively small sample sizes, (which this demo might be considered.) The first take's results were a fairly strong outlier, and did not really represent what we know happens if you have a large sample size, so they did it over to get a more representative result. That's not to say that the first run was not possible/valid; it's just that it didn't really show what happens MOST of the time...
Think of it like shooting craps, or playing cards. Sometimes you get a run that is very lucky... this run CAN actually go on for quite a while... but if you stay at the table for long enough, that short burst of abnormal behavior/"luck" will be inconsequential due to the statistical probabilities...
THEADMINwashere that's why he stated it. Besides the purpose of these videos isn't to prove things that are already proven, but to inform others about these proofs.
THEADMINwashere OK so if you go out to prove to someone that a junk hand in poker is the most common, then immediately on the first one you get a royal flush, then by your logic that means the person trying to prove this is wrong. You have flawed logic. You fail to realize that when probability is being considered, things can happen that may be counterintuitive just because of the probabilistic nature of the game you are playing. But just because they happened doesn't mean they are wrong, just very uncommon.
@THEADMINwashere You incorrectly assume that the goal of the video was to show that this always happened, when the ACTUAL goal was, well, not even to show that it happens more often, the actual goal was to EXPLAIN THE CONCEPT, and as part of that explanation, they would show the more likely possibility. The actual series they show is nothing but a backdrop for the explanation, to make it more entertaining and to make it easier for the viewer to understand.
To get the first H, it's the same for both.
a) If you get H then, but needed T, you have another chance for T right away.
b) If you get T then, but needed H, you have to wait for another H first. So it takes longer.
It's the most sensible explanation for the Expected Wait Time; weird how it wasn't mentioned in the video.
I was gonna write the same thing. It's very intuitive. No need to think about overlaps at all.
this comment made more sense than the whole video itself. You should start a channel
Indeed the same event occurs right after a win: with a H-H win, it's "easier" so more likely to get a win because you already got a H, but after a H-T win you have to "start all over again". The event you described is compensated by this one, and the difference of number of flip is just related to the way you count your points :)
Thank you, much better way of explaining it.
"...take the flipping coins."
Why is he cursing?
They are coins for flipping.
They are flipping coins.
that's the joke, my friend
time-stamp please!
false.
James Grime must be the coolest guy ever
An other way to look at this result :
When you're looking for HT, you wait until you find a H, but then if it fails, it means the next coin is still a H, so you get an other try right away (and so on until you get a T and win)
When you're looking for HH, as previously, you wait until you get a H, but then if you fail, it means you got a T. So you have to start looking for a new H before you get another try.
I like this explanation!
I like this explanation better than the one in the video.
Explained better than James Grime.
This needs to be the top comment
I'm kind of baffled people think this is a better explanation.
I didn't like his 50-coin sequence, so I wrote some code and did 1000000 iterations on my computer and it averaged to 4.002804 and 6.000917.
btw, for 3 flips:
HHH ≈ 14
HTH ≈ 10
HHT ≈ 8
HTT ≈ 8
Awesome! And thanks for the additional data :P
dont just say that without showing the code
In java it should be something like this:
class CoinFlip {
int heads = 0;
int tails = 1;
int[] sequenceOfCoinflips = new int[1000000];
int numberOfHeadsHeads = 0;
int numberOfHeadsTails = 0;
void createArray() {
for (int n = 0; n < sequenceOfCoinflips.length; n++) {
sequenceOfCoinflips[n] = (int) (Math.random() * 2);
}
}
void watchForHeadsTailsOrHeadsHeads() {
int n = 0;
while (n < sequenceOfCoinflips.length) {
if (sequenceOfCoinflips[n] == heads && sequenceOfCoinflips[n + 1] == tails) {
numberOfHeadsTails++;
n = n + 2;
} else {
if (sequenceOfCoinflips[n] == heads && sequenceOfCoinflips[n + 1] == heads) {
numberOfHeadsHeads++;
n = n + 2;
} else {
n++;
}
}
}
}
public static void main(String[] args) {
CoinFlip c = new CoinFlip();
c.createArray(); c.watchForHeadsTailsOrHeadsHeads();
System.out.println("number of heads-heads= " + c.numberOfHeadsHeads);
System.out.println("number of heads-tails= " + c.numberOfHeadsTails);
}
}
Kyon #15532
The one I pasted is already in Java.
*****
As long as you're offering up your own version, I will criticize it by saying that the way you have structured your code doesn't nicely generalize to longer sequences (3 flips or 4 flips). Compare my code or the jsfiddle pasted in another comment, which easily adapts to 3-flip sequences like HTH.
I love that outtake at the end!
I've occasionally done probability experiments as part of a class, and I always seem to be the one outlier whose results don't support the intended conclusion at all. Good to know I'm not alone.
The worst thing is of course that probability dictates that probaility experiments should fail occasionally ;)
Next time he should do it with a thousand coins ^^
even if he did it with a googol amount of coins, there is still a probability that he would get the "wrong" result :P
But a very little probability of the wrong result.
It seems many people want to know the explanation behind E(HT)=4 and E(HH)=6, and I figured out why not too long ago.
First let's look at how long it takes to reach HT on average by looking at this example sequence here:
TTTTHHHT
In a sequence that reaches HT at some point, there will be a string of T before an H comes up (length of string of Ts could be 0) and then a string of H's before the final T that ends the game, here's how the example sequence is chopped up accordingly:
TTTTH HHT
The math I use makes use of the fact that the first H to show up is grouped with the sequence of T's so that if there are no H's in the second sequence and just a T, the H in the first sequence will still make the game end with a proper HT.
Now here's the equation that shows the average number of coin flips to go from a string of T's then reach an H:
E(H) = 1 + 1/2 * ( 0 + E(H) ) --> E(H) = 1 + 1/2 * E(H)
If you don't get how I got this, here's the way I think of it: you have a coin and you want to keep flipping it until you get a H. Of course, you have to flip the coin at least once before you can see if you have to stop. Now you have a 50/50 chance of getting the H you're looking for and stop there, or you have to go through the whole process over again.
1/2 * E(H) = 1 --> E(H) = 2
Here, I did some basic algebra to find that the expected number of flips to reach H is 2, but what about from this point to reach T, that is E(T)? Turns out, it's the exact same as E(H), which is 2 because of the symmetry of the situation. Going from a string of T's to an H is mathematically the same as going from a string of H's to a T. So now we add 2 and 2 to get E(HT) = 4, which is what the video says.
Now what about E(HH)?
It turns out, the math behind this is slightly different, but still quite simple! We will use the same logic for the first step for finding E(HH). Remember that E(H) = 2, since we need to get an H in order to make progress. Here's another example sequence to illustrate:
TTTTTH?
Here, we make an important coin flip, and either we get another H and end the game, or we get a T and we start over again, each with a 50/50 chance. Turning this logic into an equation gives this:
E(HH) = E(H) + 1 + 1/2 * ( 0 + E(HH) ) --> E(HH) = E(H) + 1 + 1/2 * E(HH)
We do a bit of clean up and we get this:
E(HH) = 2 + 1 + 1/2 * E(HH) --> E(HH) = 3 + 1/2 * E(HH) --> 1/2 * E(HH) = 3 --> E(HH) = 6
And that's the other number the video gives! I usually don't explain stuff like this since other's are better at explaining, but I feel my reasoning towards these results are valid. If I made things a tad unclear at some point, tell me, and I'll edit this comment accordingly.
That is one of the best worded explanations of anything I've seen in a UA-cam comment section. It was very useful.
you missed a coma right there
I'm still confused as to why you added E(T) to E(H) when getting E(HT), but wrote out that equation for getting E(HH). Shouldn't E(HT) = E(H) + 1 + 1/2 * ( 0 + (HT) ) -->E(HT) = E(H) + 1 + 1/2 * E(HT) --> E(HT) = 2 + 1 + 1/2 * E(HT) --> E(HT) = 3 + 1/2 * E(HT) --> 1/2 * E(HT) = 3 --> E(HT) = 6 ?
I'm really confused about this whole scenario, shouldn't the game continue until you flip H, at which point there's a 50/50 chance of either H or T? Why is flipping a T more likely than flipping an H? This sounds like gambler's fallacy, but I'm really not sure what's going on.
***** you missed another coma
The main difference from how I understand the problem is that, once you reach an H, for the HH player, you got to have an H to end it. But, if you don't, you have to start over at the beginning. While for the HT player, if they don't get a T immediately, the H that they got is already half of the sequence they need again.
I am *NOT* first, and i am *NOT* happy with that. And you *DON'T* care. Go *AWAY.*
Ok I will
Ok.. Ok..
...
**stupidly yells at screen**
You got it. Take my like.
._.
Marry me ;-;
at the end of the video I was really just asking myself which kind of person watches such things.....but then, well.....
A bit similar to the common occurence of people who, upon losing at videogames, call their opponents noobs... :)
metallsnubben exactly ;-)
+metallsnubben 😂😂
I didn't understand the game at first which made the entire video confusing. I thought they both would start a new game as soon as either of them found their pair. I didn't realize that they were basically playing two different games.
If you think about it, the fact that HT happens 1 in 4 times is just because of the probability of it happening at all. HH is 50% less likely since there is a 50% chance the coin flip after the HH is heads which would overlap. That makes it 1 in 6. Very simple, logical math!
Except for whether you're looking for HH or HT, the rules for both games _are_ the same. When you get HT, you're done and start a new game. It just doesn't matter as much in this case, as the overlap can't happen anyway.
Analyse this: you're looking for HT, just flipped a H, and now you're flipping another H. You didn't get what you wanted, but you just got another chance of completing the desired sequence.
Now imagine: You want HH, just got a H, and now a T. In this case, not only did you fail to get the sequence immediately, but you also have to first flip another H before you even get another chance!
Therefore, the wait for HH is longer on average.
Smear the tails side with peanut butter or jam and it will always land heads up.
Or just put it on the back of a cat, same effect
Or combine both to obtain an infinite cycle of energy.
It's noteworthy however, that the cat rule does not apply if the flight is horizontal. My neighbour proved it.
Also attach a cat somehow for extra infinite energy
+Cory Pelizzari (SolonoidStudio) someone made a video showing that, pretty funny!
I was expecting a proof on those values. Kind of sad...
I am capable of doing it myself, still expected it to be in the video though
+Luiz Sarchis It's basic probability the cool thing, the one showed in the video, is why the more intuitive approach is wrong but once you notice the overlapping the bare calculations are quite trivial
I though the explanation someone gave on the comment section was better and more intuitive.
If you are looking for a HT and you get H, if you miss (gets H) you have another shot right away.
If you are looking for a HH and you get a H, if you miss (gets T) you have to reset to the position of having a H. This should make this sequence longer
Luiz Sarchis
It's the same thing, I thing it's just as clear.
I mapped out the possible patterns for wait times up to 9, and it was rather interesting to me, since I'm a computer engineer.
Waiting for HT is like edge-detection, and the number of possibilities grows only linearly. You can see the sum in wolfram alpha with this input: sum((n+1)n/2^(n+1))
Waiting for HH is like looking for non-glitching data. (That is, you can switch between H and T as often as you like, but you must only hit H once in a row before the termination sequence.) Curiously, the number of possibilities follows the Fibonacci sequence. The numerator grows much faster than HT's (but still much slower than the denominator), so the tail is longer. wolfram alpha: sum((n+1)Fibonacci[n]/2^(n+1))
They converge on 4 and 6 respectively, just as stated in the video.
Rosencrantz would be the undisputed king of the "heads-heads" version of this.
I thought the same :)
No! He just not-is on the boat ;) . Once again.
numberphile this is your 360th video it sould have been about angles and circles
Coins are circular
Maybe they just refused to do so because, as they should, they think only radians should be used!
He uses radians.
radians > all
Is there anyone else who loves hear James Grime talking? Can he please make Podcast where he just talks about random stuff? 😅
Well, as close to random as most humans are willing to accept :p
Are you subscribed to singing banana yet? If not, go and do that.
Marit Pizza He can talk about your name.
Very interesting, I hope you could also show the way you calculated the average waiting times.
What will be,
the heads or tails?
Doesn't matter, if you ask me;
my life will always be full of fails.
+Gnome Child this is the internet. You're too naive.
+Sandor M almost rhymes only really count if you say it out loud
temp=fail;
fail=success;
success=temp;
The result is null because fail was not instantiated.
1:24 That's a new GIF
I know a similar problem to this:
If one person bets for HH to come first and the other person for TH, then TH will win in 75% of the games.
But with HH vs HT, both are 50% to appear first!
Early bird gets the likes/worm, depending whether it is a tangible bird or a metaphor
With the numbers in the example, I did the maths for TT. Here the average comes out to be 47/11 or about 4.27 :p
Yeah it's not a large enough sample.
There was 30 'T' and 20 'H' on his example, so it's 'normal'.
If now you take the average between 'HH' and 'TT', compared to the average between 'HT' and 'TH', it will be better ;)
The way I thought of it was a little different, but with the same result:
Before your first H, the chance of "advancing" (i.e. the next being the desired one, in this case H) is equal whether you want to end up with HH or HT. Once you have one H, the chance of "advancing" further, and thus finishing is also the same for both end goals. But the difference lies in that, if you have one H and you want another H, but you fail, then you must have gotten a T, and you "regress" back to square one (needing two more "advances" to finish). On the other hand, if you have one H and you want a T, but you fail, then you just got an H, and all you need is a single "advancement" (in this case a T) to finish.
And Rosencrantz and Guildenstern begin their debate.....
Yay James Grime! :)
>Click on Numberphile video
>Like the video
>Try to understand whatever the fuck they're explaining
>Walk away feeling stupid but still kinda proud for watching something educational
Here's a python script to check the result :
from random import randint
nb_exp = 1000000
(s,t)=(0,0) #(HT,HH)
for i in range(nb_exp):
go_on=True
(a,b)=(randint(0,1),randint(0,1)) #2 coin flip
while go_on:
if (a,b)==(0,1) : #HT
go_on=False
s+=1
elif (a,b)==(0,0) : #HH
go_on=False
t+=1
else :
(a,b)=(b,randint(0,1)) #1 more coin flip
print(s/nb_exp,t/nb_exp)
if you see a mistake please tell me :)
For 10^7 trials I have HT = 49.9201% and HH = 50.0259%, but I'm too lazy to check the confidence interval
I´m sorry, I don´t understand any of that Calculation in the form it is :D.. I´m just curious if you also included the "starting a new game" after each HT/HH. Because I don´t really understand how it can be so close to 50/50 if you did include it! :D
You aren't just flipping two coins over and over again. You need to keep flipping coins until you see the certain sequence.
My man. **the way Denzel Washington says it**
+singingbanana: That's how maths works, right? If you don't get the result you want, you start over...? ;)
Wait, but doesn't the Law of Large Numbers state that when a sample size of n is small, strange things happen? So, if the probability of getting a heads or a tails each are 50%, shouldn't it be expected to get a consecutive repetition of say heads or tails a lot when doing small sample sizes (50 flips) and that they (probability of heads and tails) will eventually even out to 50/50 in the long run? I think that his first attempt ("fail") makes more sense.
Yes... but for the video they couldn't easily flip a million coins to make their point.
No, he explains this at the end of the video, because even with an infinite sequence, the expected waiting time for HH is 6 compared to 4 for HT because not every occurrence can be counted with a consecutive sequence like HH or TT.
If you're asking whether the occurrences of H and T will level to 50/50, yes, they do
Numberphile's answer seems incorrect to me. For HH you first a H then you need H but if T then you have to start from scratch to get HH. For HT you first need H then you need T but if H then you just try for T again until you get HT. HT never has to start from scratch until it forces a win. Hope this makes sense, or i could just be wrong.
Actually the TT number of occurrences was 11 like the HT.
huh! and with overlapping it's even more than HT.
It is because 50 flips is way too low, the statistical effects have not taken their rights over luck ;)
That's why its first try did not work and he had to redraw a second time.
yep.
Middle lane motorway driving at 6:50!!!
If you are Rosencrantz or Guildenstern E(HH)=2
I needed information on the likelihood of triple heads for my quant assessment and this video did not help me :*(,
It was easy to see because whenever you miss your tails after flipping heads in a heads-tails game, you just flipped heads again and you dont have to start over, so whenever you flip a tails you are done, but when you miss your second heads in a heads-heads game, you flipped tails so you have to flip heads again before you could flip your second heads.
@ 1:24
That sack grab left me in tears xD
you should do this again with a better explanation related to statistics not related to primes, after watching this video i've been looking up this stuff for a while because it seems unintuitive, but is so interesting.
Weird explanation.
Look at all the possibilities of four coinflips. Out of 16 possibilities, HH appears 7 times, while HT appears 11 times. That's simple to understand.
Failure at making an HH makes you wait for another H. Failure at HT sets you up for another HT immediately.
I've double-checked at HH definitely appears 7 times for me in the list of 16 possibilities.
how do you find the expected waiting time? More Grime pls!
I don't understand how the explanation is correct. After each game, there is an equal probability that the new game begins with heads or tails. I don't know why the previous flip matters.
If you fail a ht then that means you got two heads, so that means you just need one more tail. If you fail a hh then that means you got ht and have to restart and get two more heads in a row
But... you can fail a HT by having TT, in which case you need 2 more (HT). And you can fail a HH by having TH, in which case you have to get 1 more head. Your statement doesn't account for all cases?
The games wernt running at the same time, so they dont interfere with each other, so.... no?
***** Except when the person starts again, they're not looking at ANYTHING. They're starting again. No matter what, you've gotta flip at least twice to win the new game you've just started. What you've just described is a gambler's fallacy. The previous game has no bearing on the new game.
Ah okay, your use of the words 'starts again' threw me off. I thought you were referring to when a player completes their pattern, and started fresh.
Or you could have just flip a one pound coin once! I totally got the hang of this math stuff.
This video was flippin' great
I quickly did the Math for TT on his sequence and you get 4.27 as an average. That's without the overlaps as well. Granted over a longer period I'm sure he's right, but 50 flips doesn't really hold up.
If the sequence was longer, do you think it should get closer to the HH outcome? I would assume so. It's an interesting result nonetheless.
It should do, yes. Or at least approach identical as the sequence approaches infinite length. The interesting thing though is that the more HH:s you have in a finite sequence, the fewer TT:s you would be expected to have, just because more of the coins needed to have come up heads for the HH:s. So if you look at any one finite sequence, especially a short one such as this, it's should be a bit unlikely to get identical values for TT and HH, even though they share both equal probability *and* expected waiting time
That moment you realise there are 11 occurences of TT
An unintuitive result indeed... especially considering that when searching for HT, you can't get an overlap. I expected them to be rather equal even without counting overlaps. Roll 4 coins, and if you're not counting overlaps, HH and HT can each appear a maximum of 2 times. If you ARE counting overlaps, your maximum HH is 3 while your maximum HT is only 2. Roll 6, and it's 5 vs 3. N - 1 vs N / 2, I suppose. This effect would seem to favor HH considerably, yet really it's required in order for HH to keep up with HT?
My thoughts too. So what is the mathematical explanation? :/
***** But in the examples you gave, in the case of HH, you've already got a HH match before the third toss, so the results are still skewed in HH's favor.
I see now that they're being counted independently, so HT can still happen if the third toss comes up T despite HH being matched, but that's still only a 50% of 1 HT match, whereas HH has already achieved 1 match.
It's apparent that your examples are in the "not counting overlaps" context, which is fine and should illustrate why HT has an advantage, but I'm not seeing it yet.
It may have to do with your assertion that in the case of HT, the third toss doesn't matter, which seems accurate. In that case there's already a HT match, but HH cannot match. Still, I'm not sure this effect scales up as the string gets longer.
***** Aha! I think I've got it. I was really only comparing HH and TH, but the fact that HT is on the list and scores 1 for HT but cannot score again for either is what I had missed. Thank you. I'll also browse the other discussions.
I just saw your video "Fibonacci Mystery" talking about the reminders and such.
I would love to see the Math guy talk about Fibonacci if we were using "Base 12 " (dozenal) instead of our normal decimal one.
Dou dou dou dou
Pause the video at exactly 1:25 and laugh.
Have to stop at 3:45. Your theory depends on pretending half of the outcomes don't exist? Awesome...
Is that meant to be a criticism? (I honestly can't tell, but whatever.) Think about this problem from the perspective of a naive person that knows nothing about statistics.
If you ask them to play this 'game', this is exactly what they'll do. They'll treat every attempt at the game as an independent sequence. And the sequence continues until you get a winning combination.
Clearly, in such a situation, this is the resulting outcome, because the missing outcomes cross the boundaries of what are being treated as independent sequences.
If I had the sequences HTTHHTHHTH and HTHHTHHHH
The fact that one sequence ends on H and the other begins on it is irrelevant, because I can't just arbitrarily Jam both of the sequences together.
Just like in a lottery, it doesn't matter that my number has come up in a previous game, because it doesn't count as part of this one.
Still, since I have no idea whether your statement is sarcasm, a criticism, or just that you found it amusing, I have no idea if I explained this for no reason whatsoever. XD
It's the same game. You want a new game, make a new game. Put all the coins back in the bag, and do it again. It is the SAME game. You don't pick and choose numbers and sequences from the SAME game and tell me you've developed a new system of statistics.
But pretend that you renamed each time you get HH the end of the game and started the game again. You haven't changed anything, you are just changing definitions, so you should get the same results.
Of course it changes. You can't get HT then HT again immediately after. It's not possible. So you are only discarding the chance of successive pairs in the HH case. If you create a new sequence (put them back in the bag and start again) the HT doesn't get the advantage. You HAVE to insert an arbitrary rule to make this work.
Cellus KH But there is no fundental difference between that and taking coins out of the bag until you get HH and then putting them back in again.
I know he wants to "start the game over," but why not count "H H H" as a waiting time of 1? You got "H H" twice in the course of three flips. Why throw away the 2nd flip?
the thing i thought of was that HT is more likely to occur for the following reason, if we Have a String of coin flips when we get a first heads there are only two outcomes flip another heads and still have half your sequence finished or flip a tails and complete the sequence.
For HH flipping a heads gives you half the sequences as before but if you flip a tails you are back at step 0 with nothing and must flip another head to get back to where you where.
Neat!
If you extend it to three results instead of just two, how would the expected wait times of, say, (HTH) and (HTT) compare? My gut says that the overlap effect described above would be nullified, so they would be equal, but my gut has been wrong in the past.
I guess that HTT would be more common since HTH overlaps.
HTHTH would be an overlap.
If you are interested, someone posted the answer to a different post.
"btw:
HHH ≈ 14
HTH ≈ 10
HTT ≈ 8"
No matter how long the sequence is, the problem is always going to arise if some component of the start of the sequence also occurs at the end of the sequence. Something like HTT will follow the standard (1/2)^3 because the sequence neither starts with T nor TT, and thus the start of the sequence will never overlap with the end of a preceding sequence. On the other hand, the beginning of the sequence HTH could be the end of a preceding HTH sequence, and thus it will have a longer expected waiting time. Essentially what you end up looking for is the probability that a HTH sequence will occur that is preceded by something other than a HT. Unlike the difference between HH and HT, this is pretty easy to calculate because there aren't a whole lot of permutations - either it is preceded by HT, in which case the HTH won't count, or it isn't preceded by HT, in which case it is guaranteed to count (as we'll see in a moment, it gets a fair bit messier if there is a chance that the preceding value could itself be part of a previous sequence, that is to say if the excluding sequence [i.e. HT] overlaps with the end of the original sequence). The chance of a HT is 1/4, so the chance of not being preceded by HT is 3/4. That means the chance of a HTH that counts is (3/4).(1/8) = 3/32, giving an expected waiting time of 32/3, or a tad over 10.
Let's consider something like HHH. The beginning of this sequence could very obviously be the end of a preceding sequence, so the probability definitely won't be the simple 1/8. On top of this, unlike the previous example, it's not adequate to simply calculate the chance that it isn't preceded by a H, because a preceding H could be part of a HHH sequence of its own, meaning that the new HHH would actually count. The requirement here is that we need a sequence of Hs preceding our HHH that has a length divisible by 3 if the new HHH is going to count- any sequence of length 0, 3, 6... would be fine. The chance of length zero is 1/2 (T), the chance of length 3 is 1/16 (THHH), the chance of length 6 is 1/128 (THHHHHH) - the probability of length 3(n-1) is P_n = (1/2).(1/8)^(n-1). The infinite sum of this sequence is (1/2)/(1-(1/8)) = (1/2)/(7/8) = 4/7. The chance that a sequence of Hs of length divisible by 3 will occur at any location in the bigger sequence is 4/7. Because of this, the chance of HHH is (4/7).(1/8) = 1/14, giving an average waiting time of 14.
In summary:
E(HTT) = 8
E(HTH) = 32/3 ≈ 11
E(HHH) = 14
Okay, here is just one thing I never quite understood:
Now each individual coin flip in a perfect world has assumed 50/50 chance.
If we think that the outcome is truly random it would mean it stays at a 50/50 chance, no matter how many heads we flip for example. So after the 30th head we still have a 50/50 chance of flipping a head.
But what about the law of greater numbers, isn't it more likely that tails will appear after a long period of time since the overall average of each flip-side has to be around 50%?
The law you are talking about says that as the number of flips tends to infinity our ratio should tend to 50:50. Even though 30 heads in a row is an extremely improbable event in the grand scheme of things it means very little to the ratio when we are doing a large number of trials. We can't test infinity so let's pretend we simulate 1000000 flips instead. Say that the first 30 flips are heads but after that point we did get a perfect 50:50 ratio in the next 999970 flips, we'd have 500015 heads and 499985 tails, that's a 50.0015:49.9985 ratio, which if we round to 2 d.p is 50:50. The probability of getting a tails hasn't changed we've just done so many trials that the unusual event of 30 heads in a row is pretty much insignificant to the ratio.
No, because you haven't flipped infinitely many times.
Yes and no! If I say I flipped a coin 30 times, it's pretty likely that I got a tails in one of those. Much more likely than if I flipped a coin only one time! In order for me to not get tails in those 30 flips, I would have to get all heads. That's really unlikely to happen, and would only have a 1/2^30 chance of happening. This is because we multiply the chances for each flip together; we have 30 flips, each with a 1/2 chance to get heads, so all heads would be 1/2^30.
If I flip another coin after 30 flips, then I still have a 50% chance to get heads, 50% chance to get tails, regardless of the previous flips. If the previous flips were all heads, or all tails, or half heads half tails, or mostly heads, or mostly tails, it doesn't matter; there's still that equal chance. But if we wanted to get that specific sequence of all heads, well, we would FIRST need to meet that previously mentioned 1/2^30 chance, and then meet an additional 1/2 chance. Multiply these together and you get a chance of 1/2^31 for the whole sequence in total. But each individual flip was a 50/50 chance, and it's only when combining them that we expect tails.
Ethan Mogavero Actually a really logical explanation as to why this law applies, thank you! :)
Say L(n) is the number of permutations of H and T that do not contain HT.
L_T(n) the number of permutations that end with a T and L_H(n) end with an H
L(n) = L_H(n) + L_T(n)
L_T(n) = L_T(n-1) = L_T(n-2) = ... = L_T(1) = 1
L_H(n) = L_T(n-1) + L_H(n-1) = 1 + L_H(n-1) = ... = 1 + 1 + 1 + 1 + ... + L_H(1) = n
then:
L_T(n) = 1
L_H(n) = n
L(n) = 1+n
Say Y counts the number of coin flips until HT is reached
the probability of Y being equal to n is:
P( Y=n ) = (1/2)*(1/2) * (1/2)^(n-2) * L(n-2) = (n - 1) / 2^n
and its expected value E(Y)
E(Y) = sum from 2 to infinity of [ (n-1) * n / 2^n ] = 4
__________________________________________
For HH
Say L(n) is the number of permutations of H and T that do not contain HH.
L_T(n) the number of permutations that end with a T and L_H(n) end with an H
then
L(n) = L_H(n) + L_T(n)
L_T(n) = L_T(n-1) + L_H(n-1)
L_H(n) = L_T(n-1)
X counts the number of flips until HH is reached
P(X=n) = (1/2)*(1/2) * (1/2)^(n-2) * L_T(n-2) = L_T(n-2)/2^n
and its expected value
E(X) = sum from 2 to inifinity of [ L_T(n-2) * n / 2^n ] = ... (I haven't done it)
1:18 I thought he was gonna do an Algorithm xD
For those that want a proof
First let us start off with E(HT)
Let V = indicator variable, V = 1 if success, and 0 otherwise.
This is called a Bernoulli trial (aka a coin flip with 0.5 probability)
The waiting time for the first success in a sequence of n Bernoulli trials is something called a geometric distribution.
The expected value of a geometric distribution is (1/p) => for a coin toss p = 0.5
- E(H until T) = E(H + T) ~ E[Geo(0.5) + Geo(0.5)] = 2 + 2 = 4
Now for E(HH) (let V+1 = the next coin toss after the first heads, and H be first head)
- E(H until H) =
- = E(V) = E(H | V+1 = 0)P(V+1 = 0) + E(H | V+1 = 1)P(V+1 = 1)
- = E(H + 1) * (1/2) + E(H + 1 + V) * (1/2)
- = (2 + 1)* (1/2) + E(V)*(1/2) + (2 + 1)*(1/2) =>
- (1/2)E(V) = (3/2)*2 =>
- E(v) = 6 =>
- E(HH) = 6
For an explanation of why E(HH) = 6, lets look at the probability of getting HH. This is 1/4, however, let us now take account of overlaps.
If we have HHH, that's one extra HH that we're missing. If we have HHHH, thats two extra overlaps we're missing, etc. Also, the probability of getting HHH is 1/8, the probability of getting HHHH is 1/16, etc. Look up the inclusion-exclusion formula, and you get that the probability of getting HH is now 1/4(probability of just HH) + (-1/8 + 1/16 - 1/32 ...)(account for overlaps) = 1/4 - 1/12 = 1/6. Therefore E[HH] = 1/(1/6) = 6.
Numberphile could fuck with us so hard on 1st april, by saying somthing like "E(HT) = 4, E(HH) = 6, E(TT) = 8" XD
Not only do you have missing occurrences, but you also skipped a count in the steps in order to make that possible. For example, HTHT, you would say that HT lands on 1 and 1, but at the game end, the sequence stepper shouldn't be pushed to the sequential check....so the real value should be 1 and 2. This would not only count all occurrences, but also have a matched count average between them.
Programming wise, it would look like this:
avg = 0;
cnt = 0;
c = 1;
for(x = 1; x < L; x++)
{
if(substring(S, x, 2) == check)
{
avg = (avg * cnt + c) / (1 + cnt++);
c = 1;
} else c++;
}
Notice "x" is incremented by 1 continuously....the video would suggest that you would bump +1 when the test is true, but that's not how sequential checks on a set work. So either it's x++ or it's x+=2.
I must admit, I'm a little bit sad that you didn't show how to derive the result that the average waiting time for HH (or TT) under the game rules would be 6. As far as I can tell, the way to approach it would be knowing that, according to the rules of the game, a HH only counts if it's preceded by an even number of heads. That could be 0, 2, 4, etc... as long as it's even, the HH event will count as a success. The reason for this is that an even number of heads will pair off neatly, leaving the new HH pair as a success on its own. An odd number of heads would need to "steal" the first H in our HH pair, and thus the new HH wouldn't count as a success. This immediately highlights why there'd be a different expected waiting time - if you're waiting for HT, the criterion is simply the occurrence of a HT event. If you're waiting for HH, however, you're waiting for an even number of heads followed by a HH event.
To work out the probability of a HH success, we start with the knowledge that a HH event itself has a 1/4 probability. The events that precede it are independent, so the probability of an even number of heads followed by a HH is simply the probability of any sequence of heads of even length multiplied by 1/4. This is where things get a tad trickier. The probability of a length zero sequence of heads is 1/2 - i.e. the probability of a single tail. The probability of a length two sequence of heads is, slightly counter intuitively, 1/8 - for it to be length two, it needs to be preceded by a tail, so it's actually the probability of THH rather than just HH. This pattern continues - the probability of a length four sequence is that of THHHH, so 1/32. In other words, we're forming a geometric sequence of the form P_n = (1/2).(1/4)^(n-1). Fortunately, there is a formula for the infinite sum of a geometric sequence of the form t_n=a.r^(n-1) (as long as |r|
It's lucky he didn't say TT was more rare than HT, because it came up even more than HT in this set of 50 coins, at a waiting time of 4.3. (HT and TH both had 4.5)
I feel like there's a simpler way to understand this. If you are going for HT, then as soon as you flip a heads, you've basically won. You have a 50% chance of winning, but if you lose, you still have another heads. You're back to a 50% chance of winning. With HT, once you get a heads, EVERY flip is a possible winning flip. With HH, this isn't the case. If you flip a heads, then you have a 50% chance of winning. If you lose, there's a ZERO percent chance of winning the next flip. With HH, only SOME of the flips are winning flips. And if you look at the Expected waits, you can see that "some" is about 2/3.
I correctly predicted the outcome of coin flipping, 27 times in a row. One of the two guys witnessing the event, started betting against me. But I kept on winning. So he said that I was cheating due to having had lots of practice. So I let him flip the coin instead, and had him cover it up with has hand before I turned around to predict the result. I still kept on winning.
He kept doubling his bets, so by now he was in deep trouble. So I stopped the predicting, and said forget about the bets.
Who knows how much longer it would have gone on.
would this reason be logically correct ?
HT should occur sooner because of the following;
When a "H" is observed, there is always an equal probability of the next flip being H or T. However, if there have been N number of flips preceeding this "H" observation, only 1 path could have resulted in HT not having been observed in the prior sequence (T,T,T... for N times) but there exists many paths where HH would not have been observed (H,T,T,H,T .... or H,T,H,T,T ... etc.)
What if the force of the flip, the way the coin is held, the surface it falls on, the room temperature and wind is completely identical?
So it's a Laplace experiment.
There are 4 ways to flip 2 coins.
Leaving you with a 8 digit sequence of like
TTTHHTHH.... And there are a set number of permutations for this 8 digit sequence with 4of each.
And to get to the 6 wait time you need to take the probability of HH (0.25) and multiply it by the joint probability of THHH and HHHH and also subtract HH again.
Weird I looked at another game in your results. The question is, if you tossed the same side two times in a row, what's the chances the 3rd toss will be the same side? Some would say 50-50, I would think it would be less than 50-50 due to the need to have the same side 3 times in a row. However, in the results here the same side, after two in a row, comes up 8 times versus 4 times it was the opposite. Odd.
The fact the coins didn't fall for your little game the first time is an example of probablility. Just because something is more likely doesn't mean it will happen. But you guys are waaay too smart and already know that.
This proof could be modeled as a Turing machine, yes?
Basically, with each flip, you're checking for a desired two-coin result with the previous flip, and then stopping when you get it, you're moving one step along the track at a time like a r/w head checking for valid byte headers.
...I also sub Computerphile. 💽🤓🖥
Ok.. the important concept here is "idealized".. We can replace coin fliping by a idealized 50/50 event.. for this situation we obtain that expect times (sorry for my english)..
Why is it Heads / Tails in English? We say Head / Number, because, you know, a coin has a head and a number on it.
We say "eagle" and "tails" (could also translate to obverse) in Poland. Because instead of some Queen's head, we use our National Emblem as the constant element of all denominations. Though all legitimate translating teams translate it to "heads and tails" instead. Damn it, languages.
What if there's numbers on both sides? And what if there's no number on either side?
Both do exist.
In either case, you define in advance what is side A and what is side B and then it doesn't matter what you call it. In the UK, every coin has a head on it. The opposite side is the tail.
And since i assume you are not a native English speaker. Consider the "head" to be the front of the coin and tails to be the back of the coin.
So it might just be that the "head" doesn't have anything to do with the fact that the coin depicts a head of a person. It's just the head side of the coin, I.E the front side.
in the U.S., at least, it's usually a head on one side and an eagle on the other.
I just picked a U.S. quarter at random, and it has a head on one side, and - wait for it - two heads on the other side!
(It has an image of Mount Rushmore on the tails side.)
I think this needs a more in-depth explanation. Using prime as an example is kind of odd because we've yet to fully understand the full pattern of prime vs a problem with exactly 4 unique pair. The sample experiment also won't hold if you include TH and TT since TH and TT both have 11 occurrences and the average wait are 4.5 and 4, respectively.
CAUSE HEAD HEAD HEAD look you got two head heads. HEAD TAIL
(HEAD or TAIL) only 1 head tail possible.
1:11 Oh, you lazy mathematician... I love you
This may be a stupid question, but if "random" coin flips all even out to a very specific pattern of probability (like a 50/50 chance), doesn't that contradict the idea that it is random in the first place? They are not random at all. They follow a pattern that only reveals itself as you approach infinity. If something were truly random, the probability would be unknowable even as it approached infinity, would it not?
same for throwing 3 dice - The chance that a six appears in any throw is smaller than 50%. Because if you throw 2 or 3 sixes you count it only once.
Let's say I start flipping coins until I get Heads. So the sequence looks like H or TH or TTH or TTT...H ...
After that, there's an equal chance that my next coin will be heads or tails right? So there's an equal chance the HT or HH sequence appears first.
Didn't watch through, but the premise for the video is wrong. On a two toss coin toss, the probability of HT, HH, TH, TT is each one in four. In a sequence the probability change.
Thanks to all who explained the 4 and 6, got it. But, this same series of flips yield a much different result if you had chosen TT instead of HH, so....? Just would've needed more flips to get to the proper average?
I think another reason that this effect may take place is because as soon as you get a head you've basically got it. Should you get heads and then not 'win' per say, you've got another head, until you win and get a tail, so in a way you're only waiting for that 50% flip after you get heads.
H - need tails
HH - a tails next still works
HHH - so on
HHHT - got it
Whereas with double heads the chance resets in a way when you get tails.
H - need heads
HT - resets, now need another two heads
HTH - need heads
HTHH - got it
Correct me if i'm wrong.
I feel like I should point out that, with this low number of coin flips, picking TT as your example would have ruined the video, as the average wait time for TT was only 4.27 flips.
What utter rot. Heads will follow tails as often as tails will follow heads.If there is an equal chance of the same or different outcome, the subsequent outcome is 1/2. You can't say that the chance of winning is 1/3 and the chance of losing is 2/3 so the chance of neither is 2/3 - 1/3 = 1/3.
So does it works in perfect random? And there is a problem, you're counting units of 1 number, you're waiting for T, after it you waiting H right after it, but you need count pairs, because in line HTHTHTHTHT only 5 pairs of HT, no 4 pairs of TH
S1 : last one is tail or first time toss
S2: last one is head
first start with S1 S1 has 1/2 chance to go S2 and 1/2 chance to go S1
Expected toss form S1 is
S1 = 0.5 S1 + 0.5 S2 + 1
What's the expected waiting time of heads-heads if you include overlaps? Is it the same as heads-tails?
If you include overlaps, you're no longer asking how ling it takes to get heads-heads. Now you're asking how often they pop up.
+KohuGaly It's still asking how long it takes to get heads-heads. You just count an overlap as 1 iteration away, whereas without overlaps the shortest chain you can get is 2 iterations away. This is different from saying how often they pop up, because if we were to continue this infinitely, as was alluded in the video, what I said would lead to an answer, in this case 4, what you said would lead to "infinitely many times", because there is no restriction to how many times they occur. The same would happen even if we didn't count overlaps. I think you got confused about what the difference between our questions was. If you're interested in your question, the answer on average is (number of iterations)/(expected waiting time). If you're interested in my question, I found out in a different comment chain that the expected waiting time is 4, if you count overlaps. The other chain I'm referencing talked about it by writing some Java code.
I believe it would be, yes.
first video of the day before I start another day of crunch week for the M.A.S. at CSU. Now I'll be a lot more skeptical. I'm not really satisfied with the explanation here either.
Man, I always have that doubt. Doesnt it means that the gambler fallacy is not realy a fallacy?? Please, dig more into this subject.. thankyou very much..