WEBVTT
Kind: captions
Language: en-GB

00:00:08.023 --> 00:00:08.400
[music]

00:00:08.400 --> 00:00:13.080
Eight years ago, a younger version&nbsp;
of me sat down and flipped a coin&nbsp;&nbsp;

00:00:13.080 --> 00:00:18.240
10,000 times. If you're wondering&nbsp;
why would anyone do that,&nbsp;&nbsp;

00:00:18.240 --> 00:00:23.920
look, we don't welcome those sorts of questions&nbsp;
around here. But more to the point, I want to see&nbsp;&nbsp;

00:00:23.920 --> 00:00:31.280
how often it would land on its edge. And later on,&nbsp;
I'll explain why I was doing that, how many times&nbsp;&nbsp;

00:00:31.280 --> 00:00:35.960
it landed on its edge if you want to see if you&nbsp;
can have a guess. 10,000 flips, how many edges,&nbsp;&nbsp;

00:00:35.960 --> 00:00:41.440
and I have a ridiculous joke collaboration we&nbsp;
shot, which has never seen the light of day.&nbsp;&nbsp;

00:00:41.440 --> 00:00:46.480
That'll be right at the end of the video. See if&nbsp;
you can guess who else is involved. But for now,&nbsp;&nbsp;

00:00:46.480 --> 00:00:51.360
we're going to speed forward 8 years to&nbsp;
when these flips finally became useful.&nbsp;&nbsp;

00:00:52.040 --> 00:00:57.520
That's because of Pi Day. Yes, a few years ago I&nbsp;
flipped a coin 10,000 times. I don't know what I&nbsp;&nbsp;

00:00:57.520 --> 00:01:02.240
was thinking, but I've finally come up with a use&nbsp;
for that footage. I'm going to use it this Pi Day.&nbsp;&nbsp;

00:01:02.240 --> 00:01:06.760
So, hey, happy Pi Day 2026. Although, shouldn't&nbsp;
have said that. Forget [music] it's Pi Day.&nbsp;&nbsp;

00:01:07.360 --> 00:01:12.120
Spoiler. This is not a video about that.&nbsp;
This is a video about flipping a coin to&nbsp;&nbsp;

00:01:13.040 --> 00:01:20.240
about flipping Thank you. a coin to see&nbsp;
what the ratio between heads and tails is.

00:01:28.240 --> 00:01:33.240
Yes. Late last year, a new bit of math&nbsp;
dropped relating to if you flip a coin,&nbsp;&nbsp;

00:01:33.240 --> 00:01:39.000
keep track of if it's heads or tails, and you&nbsp;
stop when there are more heads than tails.&nbsp;&nbsp;

00:01:39.000 --> 00:01:43.080
And let's say you do that over and over. And&nbsp;
then you ask the question, hang on a second. If&nbsp;&nbsp;

00:01:43.080 --> 00:01:48.440
I stop whenever there are more heads than tails,&nbsp;
what's the average ratio of all those sequences&nbsp;&nbsp;

00:01:48.440 --> 00:01:51.640
where I compare the number of heads to the&nbsp;
number of tails? And there's going to be&nbsp;&nbsp;

00:01:51.640 --> 00:01:59.000
more heads than tails, but how many more? And if&nbsp;
you calculate that and work it out in general,&nbsp;&nbsp;

00:01:59.000 --> 00:02:04.080
turns out, and yes, this is why it's a Pi&nbsp;
Day video. And look, I'm as angry as you are.&nbsp;&nbsp;

00:02:04.800 --> 00:02:13.920
It's pi. It's pi on four. If you flip a coin until&nbsp;
there are more heads than tails, the ratio is pi&nbsp;&nbsp;

00:02:14.480 --> 00:02:19.960
on four. So that's what we're going to do. This&nbsp;
Pi Day, I'm going to calculate pi from my 10,000&nbsp;&nbsp;

00:02:19.960 --> 00:02:24.640
coin flips, which has actually come together quite&nbsp;
well. Previously, this Pi Day was going to be&nbsp;&nbsp;

00:02:24.640 --> 00:02:29.480
us calculating pi on the moon. You may have seen&nbsp;
the update about that that went out recently.&nbsp;&nbsp;

00:02:29.480 --> 00:02:33.840
Sadly, like a lot of space missions, it's been&nbsp;
delayed. So, we can't do that. That would be next&nbsp;&nbsp;

00:02:33.840 --> 00:02:39.000
Pi Day hopefully. Previously, previously,&nbsp;
there should have been a Pi by hand year.&nbsp;&nbsp;

00:02:39.000 --> 00:02:42.160
I was going to try and break the record. Turns out&nbsp;
that's going to take longer than I expected. So,&nbsp;&nbsp;

00:02:42.160 --> 00:02:46.920
that's also delayed, but will happen. link in the&nbsp;
description if you want to sign up for updates.&nbsp;&nbsp;

00:02:47.520 --> 00:02:51.360
So, what I'm going to do is basically go back to&nbsp;
normal. I'm going to do a standard pi by hand,&nbsp;&nbsp;

00:02:51.360 --> 00:02:56.960
but this time instead of doing long tedious&nbsp;
working out by hand, I've previously flipped&nbsp;&nbsp;

00:02:56.960 --> 00:03:05.600
a coin 10,000 times by hand. And from that, we&nbsp;
can extract a value of pi. And unbelievably,&nbsp;&nbsp;

00:03:05.600 --> 00:03:12.680
no one noticed that you get this value of pi on&nbsp;
four from multiple coin flips until last year.&nbsp;&nbsp;

00:03:12.680 --> 00:03:16.480
And so I'm like, well, this is great. Breaking&nbsp;
news. So here's what we're going to do. I'm going&nbsp;&nbsp;

00:03:16.480 --> 00:03:22.480
to explain why you get pi when you flip a coin.&nbsp;
Then we're going to get pi from flipping a coin.&nbsp;&nbsp;

00:03:23.480 --> 00:03:27.200
Let's do it. Right. I'm going to use these to&nbsp;
represent a sequence of heads and tails. We&nbsp;&nbsp;

00:03:27.200 --> 00:03:31.240
can kind of arrange them across here.&nbsp;
And actually before we even start,&nbsp;&nbsp;

00:03:31.240 --> 00:03:37.360
we've got a pretty tight range on what the average&nbsp;
ratio can be. Because the highest it can be is if&nbsp;&nbsp;

00:03:37.360 --> 00:03:42.600
boom, straight out of the gate, you flip a heads.&nbsp;
You've now got more tails than heads as required&nbsp;&nbsp;

00:03:42.600 --> 00:03:48.720
and it's 100% 100% heads. It's the highest&nbsp;
possible ratio. Or we could have like, you know,&nbsp;&nbsp;

00:03:48.720 --> 00:03:54.600
thousands of flips before eventually we have&nbsp;
more heads than tails. And when that happens,&nbsp;&nbsp;

00:03:54.600 --> 00:04:02.560
it will have just because there's so many just&nbsp;
gone over 50%. So really our range is 0.5 to one.&nbsp;&nbsp;

00:04:02.560 --> 00:04:07.360
Because we're calculating pi on four,&nbsp;
it means we've already narrowed pi down&nbsp;&nbsp;

00:04:07.360 --> 00:04:16.200
to between two and four, which you know, compared&nbsp;
to some historic pi days, we're doing pretty good.&nbsp;&nbsp;

00:04:16.200 --> 00:04:20.200
Now, what if we didn't get head straight&nbsp;
away? What if the very first flip was tails?&nbsp;&nbsp;

00:04:20.200 --> 00:04:23.480
Well, now we're going to have to keep going.&nbsp;
And the shortest sequence it could be now is&nbsp;&nbsp;

00:04:24.000 --> 00:04:29.520
three flips. It can't be two because&nbsp;
the best case scenario is we get heads,&nbsp;&nbsp;

00:04:30.120 --> 00:04:37.600
right? And but now it's 50/50. Has to be more&nbsp;
has to be greater than 50%. So potentially&nbsp;&nbsp;

00:04:37.600 --> 00:04:45.760
another heads. So now that's the Whoops. Shortest&nbsp;
sequence where it goes tails, heads, heads, stop.&nbsp;&nbsp;

00:04:46.280 --> 00:04:52.920
And that's a well, I guess that's a a half time a&nbsp;
half times a half. That's a half cubed probability&nbsp;&nbsp;

00:04:52.920 --> 00:04:58.800
of happening. And the ratio is two out of three.&nbsp;
But what if we didn't get that second heads?&nbsp;&nbsp;

00:04:59.320 --> 00:05:04.880
The next shortest would be five flips. So&nbsp;
for us to keep going in the first place,&nbsp;&nbsp;

00:05:04.880 --> 00:05:12.800
that would have to be tails there. Okay. And then&nbsp;
the next one will Oh, it has to be two more heads,&nbsp;&nbsp;

00:05:12.800 --> 00:05:17.440
right? Cuz we need to get it needs to be three&nbsp;
out of five heads for us to stop after five.&nbsp;&nbsp;

00:05:17.440 --> 00:05:22.400
So it would look like that. There it is. Okay.&nbsp;
Next shorter sequence is five. It ends on when&nbsp;&nbsp;

00:05:22.400 --> 00:05:26.840
we flip this heads. And that's the one that&nbsp;
tips us over to more heads than tails. So the&nbsp;&nbsp;

00:05:26.840 --> 00:05:31.440
probability of this sequence happening half times&nbsp;
a half times over five of them half the power of&nbsp;&nbsp;

00:05:31.440 --> 00:05:38.200
five. We can add that in and the ratio is 3 out of&nbsp;
five. Great. So we've Oh, hang on. Wait a minute.&nbsp;&nbsp;

00:05:38.760 --> 00:05:45.400
Yeah, this one works. But so does so is this&nbsp;
one. That's also a perfectly valid sequence.&nbsp;&nbsp;

00:05:45.400 --> 00:05:49.960
That's five long and would end at the same&nbsp;
point exactly when we flip that one. So there's&nbsp;&nbsp;

00:05:51.040 --> 00:05:57.280
I'll pick that up later. There's I can replace&nbsp;
it. So there's there's two of them. Okay, so now&nbsp;&nbsp;

00:05:57.280 --> 00:06:04.480
for each run of coins, we need the probability, we&nbsp;
need the ratio, and we need how many options there&nbsp;&nbsp;

00:06:04.480 --> 00:06:11.480
are. So we multiply this one by two. Let's have&nbsp;
a go at seven. Right, I've set us up seven spots,&nbsp;&nbsp;

00:06:12.080 --> 00:06:16.920
and we're going to think about what sequences&nbsp;
could possibly end at the seventh flip. And&nbsp;&nbsp;

00:06:16.920 --> 00:06:21.400
by end, it means that has to be us flipping a&nbsp;
head because that's the point at which we have&nbsp;&nbsp;

00:06:21.400 --> 00:06:26.160
more heads than tails and we stop. And at no point&nbsp;
before then can we have had more heads than tails&nbsp;&nbsp;

00:06:26.160 --> 00:06:30.360
otherwise we would have stopped including the very&nbsp;
first flip. There has to be a tails otherwise we&nbsp;&nbsp;

00:06:30.360 --> 00:06:35.080
would have stopped on the heads. The second one&nbsp;
could be heads or tails. We'll come back to that.&nbsp;&nbsp;

00:06:35.080 --> 00:06:41.880
Let's start by the case where we flip three tails&nbsp;
first. So tails are way out in front and then&nbsp;&nbsp;

00:06:41.880 --> 00:06:49.560
heads come slamming back and they get it right at&nbsp;
the end because four out of seven is the point at&nbsp;&nbsp;

00:06:49.560 --> 00:06:54.960
which this one means we've got more heads and&nbsp;
tails. So that's one. Write that down. However,&nbsp;&nbsp;

00:06:55.480 --> 00:07:00.840
this third tails here, that could happen later.&nbsp;
We could have that one was a heads and that one&nbsp;&nbsp;

00:07:00.840 --> 00:07:05.440
was a tails. That would work nicely. We can move&nbsp;
it further. That's two. If you're counting, we can&nbsp;&nbsp;

00:07:05.440 --> 00:07:12.200
move it down again. That could be uh heads. That&nbsp;
could be the tails. We can't do it again, however,&nbsp;&nbsp;

00:07:12.200 --> 00:07:18.040
because if this was heads and that was tails,&nbsp;
it doesn't work because we've already now look&nbsp;&nbsp;

00:07:18.040 --> 00:07:22.680
at that. Two tails, three heads, we would have&nbsp;
stopped. So, we only get those two extra ones.&nbsp;&nbsp;

00:07:23.480 --> 00:07:30.200
So, now we're up to uh three alto together. Now,&nbsp;
the other case was if that was a heads there.&nbsp;&nbsp;

00:07:30.960 --> 00:07:34.600
Now, if that's a heads, this one can't&nbsp;
be heads cuz otherwise we'll have more&nbsp;&nbsp;

00:07:34.600 --> 00:07:39.280
heads than tails. It's got to be tails like&nbsp;
that. And then that's still heads over there.&nbsp;&nbsp;

00:07:39.280 --> 00:07:45.280
And then these can go either way. This is either&nbsp;
a heads than a tails or it's a tails than a heads.&nbsp;&nbsp;

00:07:45.280 --> 00:07:50.200
Both of those work. You can't delay it any&nbsp;
longer. So, that that's five. If you want to&nbsp;&nbsp;

00:07:50.200 --> 00:07:55.120
pause and go through that yourself, you're very&nbsp;
welcome to. I spent a long time in my notebook,&nbsp;&nbsp;

00:07:55.120 --> 00:07:58.720
which I'm pointing down here because I've still&nbsp;
got all my This was me trying to work it out&nbsp;&nbsp;

00:07:58.720 --> 00:08:04.360
the other night, and I got all these sketches&nbsp;
of me going through being like, "Oh, what do I&nbsp;&nbsp;

00:08:04.360 --> 00:08:08.800
get in the sequence of heads and tails and tails&nbsp;
and heads? There's my there's me counting five,&nbsp;&nbsp;

00:08:09.720 --> 00:08:15.080
and I was right." So, I was able to fill that into&nbsp;
the table. And the next one, we could do it for&nbsp;&nbsp;

00:08:15.080 --> 00:08:26.560
nine. There's 14 ways to do it. I didn't bother&nbsp;
working that out. I put the sequence of 125 into&nbsp;&nbsp;

00:08:26.560 --> 00:08:33.160
the online encyclopedia of integer sequences and&nbsp;
it was all like, do you mean the Catalan numbers?&nbsp;&nbsp;

00:08:33.160 --> 00:08:40.360
And I was like, turns out I do. So why the&nbsp;
Catalan numbers? Well, to get my head around it,&nbsp;&nbsp;

00:08:40.360 --> 00:08:45.320
I then drew a diagram which I'm going to recreate&nbsp;
for you very quickly here on my whiteboard&nbsp;&nbsp;

00:08:45.320 --> 00:08:51.760
where I thought, you know what? Let's represent on&nbsp;
a kind of tree diagram. If you get a tails, you go&nbsp;&nbsp;

00:08:51.760 --> 00:08:56.920
down. If you get a heads, you go up. I had to roll&nbsp;
that in around the dog so I didn't hit the dog.&nbsp;&nbsp;

00:08:57.600 --> 00:09:03.200
And the goal is to end up above water. Very&nbsp;
simple. So, you start here on the surface&nbsp;&nbsp;

00:09:03.800 --> 00:09:10.760
and then if your first flip is a heads, you're&nbsp;
high and dry, you stop. If it's a tails,&nbsp;&nbsp;

00:09:10.760 --> 00:09:15.680
you're down here. To clarify, when&nbsp;
I mean above water, we stop flipping&nbsp;&nbsp;

00:09:15.680 --> 00:09:21.560
once we're one above this blue line. Because&nbsp;
if tails moves us down and heads moves us up,&nbsp;&nbsp;

00:09:21.560 --> 00:09:27.720
being one above our starting point means we've&nbsp;
now had more heads than tails. And then I just&nbsp;&nbsp;

00:09:27.720 --> 00:09:32.080
expanded the tree diagram because the next&nbsp;
one would bring you back up to the surface.&nbsp;&nbsp;

00:09:32.080 --> 00:09:37.600
This one would bring you even further below the&nbsp;
surface. Then you've got a chance to get out here&nbsp;&nbsp;

00:09:37.600 --> 00:09:42.200
heads. And there's only one way that that's&nbsp;
one way to do that. There's one way to do that,&nbsp;&nbsp;

00:09:42.200 --> 00:09:51.200
but there are multiple ways. If you go up here&nbsp;
next or down there and then up there and then out,&nbsp;&nbsp;

00:09:51.200 --> 00:09:53.960
then if you count that, you're like, "Oh, actually&nbsp;
there's two ways because I could have gone all the&nbsp;&nbsp;

00:09:53.960 --> 00:09:59.200
way down and all the way back and out or down, up,&nbsp;
down, up and out." And so if you start building up&nbsp;&nbsp;

00:09:59.800 --> 00:10:06.200
this diagram of all the ways you can flip&nbsp;
heads and tails and all the places you can end&nbsp;&nbsp;

00:10:06.840 --> 00:10:11.120
up and all the times that you break the&nbsp;
surface and escape and then you got to&nbsp;&nbsp;

00:10:11.120 --> 00:10:18.320
count the number of paths. Ah, you know what this&nbsp;
is reminding me of. But if we flipped it over,&nbsp;&nbsp;

00:10:19.480 --> 00:10:23.680
it's Pascal's freaking triangle. If you'd like&nbsp;
to learn more about Pascal's triangle and the&nbsp;&nbsp;

00:10:23.680 --> 00:10:28.480
Catalan numbers, my friend Sophie Mlan already&nbsp;
has a fantastic number file video all about it. I&nbsp;&nbsp;

00:10:28.480 --> 00:10:33.920
highly recommend you check that out. And it works&nbsp;
very neatly because Pascal triangle is effectively&nbsp;&nbsp;

00:10:33.920 --> 00:10:37.880
counting the number of ways you can get to any&nbsp;
given point. And we can use the Catalan numbers&nbsp;&nbsp;

00:10:37.880 --> 00:10:43.160
to normally cross over in the middle. Ah, it's&nbsp;
all it's really nice. Check out Sophie's video.&nbsp;&nbsp;

00:10:43.160 --> 00:10:46.920
But for our purposes, we're just going to&nbsp;
use the fact that the Catalan numbers counts&nbsp;&nbsp;

00:10:46.920 --> 00:10:52.440
the number of possible head or tail sequences.&nbsp;
Right now we're going to put it all together.&nbsp;&nbsp;

00:10:52.440 --> 00:10:58.600
So we can take our table from before and put it&nbsp;
into a generalized form. Catalan numbers start at&nbsp;&nbsp;

00:10:58.600 --> 00:11:05.920
n equals 0. The zeroth Catalan number which is&nbsp;
1. So we're going to use counting from zero.&nbsp;&nbsp;

00:11:05.920 --> 00:11:11.640
And the formula in general is going&nbsp;
to be 1 / 2 to the power of 2 n + 1&nbsp;&nbsp;

00:11:12.160 --> 00:11:21.280
multiplied by the nth Catalan number multiplied&nbsp;
by n +1 over 2 n + 1. That's just what we had in&nbsp;&nbsp;

00:11:21.280 --> 00:11:26.120
the table. But now you put in whatever value of&nbsp;
n and you get the next term in the series. And so&nbsp;&nbsp;

00:11:26.120 --> 00:11:35.000
we want to sum these from n equals z up infinitely&nbsp;
many of them. Then we get some result. And we do.&nbsp;&nbsp;

00:11:35.000 --> 00:11:39.920
I wrote down here last night. You can see there&nbsp;
was my terrible attempt at that tree diagram. Um,&nbsp;&nbsp;

00:11:39.920 --> 00:11:46.360
and over here next to it, I've written the formula&nbsp;
for the catland numbers. 1 / n +1 multiplied&nbsp;&nbsp;

00:11:46.360 --> 00:11:53.520
by 2 n choose n. And you can put that in terms&nbsp;
of factorials. We just substitute that in.&nbsp;&nbsp;

00:11:53.520 --> 00:12:01.640
And now we have one big chunky equation that&nbsp;
gives us each of the terms from n equals z&nbsp;&nbsp;

00:12:01.640 --> 00:12:09.400
all the way up. We just got to work out how we&nbsp;
turn that into pi. Okay, now we just need some&nbsp;&nbsp;

00:12:09.400 --> 00:12:15.560
kind of substitution or a way to rearrange&nbsp;
this to get closer to pi. What's that noise?&nbsp;&nbsp;

00:12:17.800 --> 00:12:23.760
It's arc sign. It's the inverse&nbsp;
function of sign that can be written&nbsp;&nbsp;

00:12:23.760 --> 00:12:29.440
as a series. Look at that. Isn't that amazing? I&nbsp;
mean, okay, look, here's the thing. I can't derive&nbsp;&nbsp;

00:12:29.440 --> 00:12:34.480
everything from first principles. It'll be a very&nbsp;
long and I'm aware of the things I'm about to say&nbsp;&nbsp;

00:12:34.480 --> 00:12:40.640
boring video. So at some point you've just got to&nbsp;
take something on faith and we're going to use the&nbsp;&nbsp;

00:12:40.640 --> 00:12:45.920
series expansion of aride. If you want to look&nbsp;
up how it's done, you can. In fact, it involves&nbsp;&nbsp;

00:12:45.920 --> 00:12:52.560
binomials and once again Pascal's triangle. Lovely&nbsp;
bit of mathematics. That's now your problem. All&nbsp;&nbsp;

00:12:52.560 --> 00:12:59.960
I'm saying is doesn't that look similar? In fact,&nbsp;
instead of ark sine of x, we could do ar sign of&nbsp;&nbsp;

00:12:59.960 --> 00:13:05.680
one. Just put that in. Why not? And that means the&nbsp;
x becomes one. That whole thing vanishes. And it&nbsp;&nbsp;

00:13:05.680 --> 00:13:14.440
looks pretty much exactly like what we had before.&nbsp;
In fact, it's just twice as big. It's two times&nbsp;&nbsp;

00:13:14.440 --> 00:13:20.200
whatever the average ratio of heads to tails is&nbsp;
in our previous calculation. And what's the arc&nbsp;&nbsp;

00:13:20.200 --> 00:13:27.080
sign of one? The inverse sign of one. What value&nbsp;
gives you one when you put it in sign? It's 90°.&nbsp;&nbsp;

00:13:27.880 --> 00:13:35.480
It's pi on 2. So pi on 2 equals twice the average.&nbsp;
The average is pi on four. It's still making me&nbsp;&nbsp;

00:13:35.480 --> 00:13:42.280
angry. I mean, here's the thing. We're not&nbsp;
surprised that if you flip a coin lots, the&nbsp;&nbsp;

00:13:42.280 --> 00:13:48.400
dogs come over to see why I'm getting emotional.&nbsp;
Uh, we're not surprised that stopping lots of&nbsp;&nbsp;

00:13:48.400 --> 00:13:52.440
different length sequences of flips and adding&nbsp;
them together gives us a series. That's what&nbsp;&nbsp;

00:13:52.440 --> 00:13:58.880
we'd anticipate and we're not surprised that you&nbsp;
can represent pi with an infinite series. That's&nbsp;&nbsp;

00:13:58.880 --> 00:14:06.600
classic pi. But I expect them to be separate&nbsp;
things. What stuns me is that one of the series&nbsp;&nbsp;

00:14:06.600 --> 00:14:13.880
for pi happens to match a series for flipping a&nbsp;
coin. It's ridiculous. I'm not happy about it.&nbsp;&nbsp;

00:14:16.480 --> 00:14:22.560
Thank goodness I got my therapy dog right here.&nbsp;
Oh, who's a good dog? This ridiculous pi coin fact&nbsp;&nbsp;

00:14:22.560 --> 00:14:27.600
was discovered last year by a mathematician I know&nbsp;
named James prop. And James is going to put up a&nbsp;&nbsp;

00:14:27.600 --> 00:14:32.640
blog post for this pi day going through all the&nbsp;
mathematics behind it. So I'll link to that below.&nbsp;&nbsp;

00:14:32.640 --> 00:14:36.840
You can check it out if you want to go through&nbsp;
the detail. It's even a bit of calculus in there&nbsp;&nbsp;

00:14:37.360 --> 00:14:42.360
if you're into that kind of thing. But&nbsp;
for me normally my problem would be oh I'm&nbsp;&nbsp;

00:14:42.360 --> 00:14:46.240
like a such a good fact. I need to do a thing&nbsp;
for pi day. I could sit here and flip a coin&nbsp;&nbsp;

00:14:46.240 --> 00:14:52.520
over and over and over again and calculate pi by&nbsp;
hand. But this time, I don't have to because it&nbsp;&nbsp;

00:14:52.520 --> 00:14:59.560
turns out it's already been done by my longtime&nbsp;
collaborator, past Matt. So, here's why past Matt&nbsp;&nbsp;

00:14:59.560 --> 00:15:06.760
was flipping a coin 10,000 times. I've had this&nbsp;
longunning project in my creator calculate how&nbsp;&nbsp;

00:15:06.760 --> 00:15:13.680
thick a three-sided coin would have to be, which&nbsp;
is a coin where it's equally likely to land heads,&nbsp;&nbsp;

00:15:13.680 --> 00:15:18.680
tails, or edge. And I've talked about this&nbsp;
before. or it's been on hold for a long time,&nbsp;&nbsp;

00:15:18.680 --> 00:15:23.240
but I found the current state-of-the-art.&nbsp;
But I realized the state-of-the-art was a&nbsp;&nbsp;

00:15:23.240 --> 00:15:28.760
single paper. In fact, to this day, if you go to&nbsp;
Wikipedia and look at the entry on coin flipping,&nbsp;&nbsp;

00:15:28.760 --> 00:15:35.560
the one citation for landing on edge is the&nbsp;
paper probability of a tossed coin landing on&nbsp;&nbsp;

00:15:35.560 --> 00:15:44.240
edge from 1993. So, I thought I would recreate&nbsp;
their experiments and I'll do my own experiment&nbsp;&nbsp;

00:15:44.240 --> 00:15:48.800
in an attempt to investigate that.&nbsp;
Now, I never got around to analyzing&nbsp;&nbsp;

00:15:48.800 --> 00:15:54.560
the data. I did recreate their experiment by&nbsp;
sliding the pound coin, which is what they used,&nbsp;&nbsp;

00:15:54.560 --> 00:16:01.440
off a horizontal surface a thousand times. Then,&nbsp;
I did my own 10,000 flips. I'll link to it below&nbsp;&nbsp;

00:16:01.440 --> 00:16:07.040
if you want to have a look at the data. You can&nbsp;
analyze it yourself. Uh the big reveal 14 times&nbsp;&nbsp;

00:16:07.600 --> 00:16:13.680
landed on its edge 14 times. Now this whole&nbsp;
experiment was a complete waste. It became&nbsp;&nbsp;

00:16:13.680 --> 00:16:20.040
a whole section in my book humble pie. But the&nbsp;
footage the footage I never had a reason to use&nbsp;&nbsp;

00:16:20.040 --> 00:16:26.280
until now. Until I wanted to calculate pi.&nbsp;
So here's my big spreadsheet of data. I'll&nbsp;&nbsp;

00:16:26.280 --> 00:16:29.760
link to this below if you want to check it out&nbsp;
for yourself. It's got the exact time I flipped&nbsp;&nbsp;

00:16:29.760 --> 00:16:35.920
every single coin. Wow, that was a late night.&nbsp;
And then over here, started heads, landed heads,&nbsp;&nbsp;

00:16:35.920 --> 00:16:43.360
every single landing one. And that's just my kind&nbsp;
of count count if 14 edges. Ah, good times. Now,&nbsp;&nbsp;

00:16:43.880 --> 00:16:47.640
we need to analyze this, which means we got&nbsp;
to get into Python. And I thought it might be&nbsp;&nbsp;

00:16:47.640 --> 00:16:55.080
fun to write the code. So, all I'm doing here is&nbsp;
I'm using open py. That's Python for Excel files.&nbsp;&nbsp;

00:16:55.080 --> 00:17:01.160
I've I've I've set up the name of the file and&nbsp;
everything. We want to count how many sequences&nbsp;&nbsp;

00:17:02.120 --> 00:17:06.720
we've been through and that starts with&nbsp;
zero of them. I try to have remotely&nbsp;&nbsp;

00:17:06.720 --> 00:17:13.960
useful names. That's also zero. And then for each&nbsp;
one, we need to count two things. How many heads&nbsp;&nbsp;

00:17:14.920 --> 00:17:19.000
and how many flips? What are&nbsp;
we going to do with edges?&nbsp;&nbsp;

00:17:20.400 --> 00:17:26.000
Let's ignore them. [laughter] Let's say they&nbsp;
don't they don't count. They don't count. It's&nbsp;&nbsp;

00:17:26.000 --> 00:17:37.400
got to be heads or tails. Lowerase H or T. So what&nbsp;
we'll do now is if the flip result equals heads&nbsp;&nbsp;

00:17:38.840 --> 00:17:55.280
then we increment head count. So that goes up by&nbsp;
one. And then if flip result doesn't equal e then&nbsp;&nbsp;

00:17:55.920 --> 00:18:00.920
that's our total number of flips. Okay. So, all&nbsp;
I've done there is each time we flip it, if it's&nbsp;&nbsp;

00:18:00.920 --> 00:18:06.400
heads, we add to the running head count. If it's&nbsp;
not edge, we add to the running total number of&nbsp;&nbsp;

00:18:06.400 --> 00:18:13.040
flips count. Great. Now, we got to check if we've&nbsp;
hit the end of a sequence. So, if that happens,&nbsp;&nbsp;

00:18:13.920 --> 00:18:19.120
we want to work out the ratio of heads to tails in&nbsp;
that run. So, we're going to say this ratio equals&nbsp;&nbsp;

00:18:19.720 --> 00:18:25.840
uh headcount divided by flip count. I could&nbsp;
do all this in one big long chunky line.&nbsp;&nbsp;

00:18:25.840 --> 00:18:29.120
I like to split things out because it makes my&nbsp;
life a little easier to try and read it. So,&nbsp;&nbsp;

00:18:29.120 --> 00:18:35.240
I'm going to take running ratio total add on&nbsp;
this ratio. And we've had one more sequence.&nbsp;&nbsp;

00:18:35.760 --> 00:18:42.120
So, uh what do we call our sequence count? Count&nbsp;
sequences. Well done. Pass mat always there for&nbsp;&nbsp;

00:18:42.120 --> 00:18:48.360
me. So, we add one onto that. Now, we want to&nbsp;
reset cuz we're going to start another run. So,&nbsp;&nbsp;

00:18:48.360 --> 00:18:54.960
flip count and head count now get set back to&nbsp;
zero. Okay, that should be everything. Oh, that's&nbsp;&nbsp;

00:18:55.480 --> 00:18:59.000
I can't increment flip result. That's&nbsp;
what I It's flip count. What a dingus.&nbsp;&nbsp;

00:18:59.600 --> 00:19:07.880
Okay, that fixed. I kind of want to check it's&nbsp;
working before we get the big result. Let's run&nbsp;&nbsp;

00:19:07.880 --> 00:19:13.440
it first without calculating the result. That's&nbsp;
the big reveal. Each time we'll print the result&nbsp;&nbsp;

00:19:14.200 --> 00:19:20.880
and then down here we'll print what we think&nbsp;
the ratio was. Okay, so now we can run it.&nbsp;&nbsp;

00:19:21.720 --> 00:19:26.200
It'll do that for all 10,000 flips. make sure it&nbsp;
functions and make sure it's doing what we expect.&nbsp;&nbsp;

00:19:26.200 --> 00:19:32.560
You never know with code. It's like if you just&nbsp;
run it without making sure you've gone through to&nbsp;&nbsp;

00:19:32.560 --> 00:19:36.480
make sure everything's working properly. It's&nbsp;
a very opaque process which makes me nervous.&nbsp;&nbsp;

00:19:37.400 --> 00:19:42.120
Ah. Oh, there it is. It ran. Oh, these&nbsp;
are long runs. Oh, okay. It is working.&nbsp;&nbsp;

00:19:42.120 --> 00:19:48.480
So, that was a super long run. Look at it. And&nbsp;
when it finally ended, it was just over a half.&nbsp;&nbsp;

00:19:48.480 --> 00:19:57.120
Next one was a heads. So, it was one heads was&nbsp;
one. So this was a total of 1 2 3 4 5 6 7 8 9&nbsp;&nbsp;

00:19:57.120 --> 00:20:08.320
10 11 flips of which one two three four five six.&nbsp;
So yeah, so it was five and five. One more heads&nbsp;&nbsp;

00:20:09.040 --> 00:20:17.680
tipped it over to six and five. It stopped and&nbsp;
ratio 54.54%. Okay, I'm happy the code is working.&nbsp;&nbsp;

00:20:17.680 --> 00:20:25.360
I'm going to undo that one. Now once&nbsp;
it finishes running, let's just print.&nbsp;&nbsp;

00:20:27.360 --> 00:20:33.760
Should we do it all at once? Should we just print&nbsp;
pi? Let's just print pi. You know what? Let's do&nbsp;&nbsp;

00:20:35.040 --> 00:20:44.160
pi val equals running ratio total divided by count&nbsp;
sequences. So that's the total of all the ratios&nbsp;&nbsp;

00:20:44.160 --> 00:20:48.680
divided by how many there are. That gives us&nbsp;
the average. And then we multiply that by four.&nbsp;&nbsp;

00:20:49.600 --> 00:21:00.320
And then we print pi val. So this is it folks.&nbsp;
This is the value of pi for pi day 2026.&nbsp;&nbsp;

00:21:00.320 --> 00:21:04.560
We're going to zoom. Let's get right in. I know&nbsp;
that's messy, but I want a big number. Okay.&nbsp;&nbsp;

00:21:04.560 --> 00:21:13.120
Ready? Okay. Here we can't see producer Nicole is&nbsp;
just out of shot over there. Very excited. Camera&nbsp;&nbsp;

00:21:13.120 --> 00:21:23.880
person Alex is over there wildly indifferent.&nbsp;
And now we run the code. 3.2266. [music]

00:21:24.480 --> 00:21:34.880
That's better than I was braced for&nbsp;
cuz it converges so slow. Wow. 3.2266.

00:21:35.560 --> 00:21:41.960
For everyone who keeps a running record of&nbsp;
my successes and failures, write that down.&nbsp;&nbsp;

00:21:42.960 --> 00:21:47.480
That's good stuff. Obviously, while I was&nbsp;
flipping a coin 10,000 times, I had a bit of fun.&nbsp;&nbsp;

00:21:47.480 --> 00:21:51.480
did some ridiculous bits to camera and then I&nbsp;
thought, you know what? Why don't I try this&nbsp;&nbsp;

00:21:51.480 --> 00:21:57.280
in a fake collaboration where a coin&nbsp;
unexpectedly keeps landing miraculously&nbsp;&nbsp;

00:21:57.280 --> 00:22:02.280
on its edge. In a previous video, I said there&nbsp;
was a trivial chance when you flip a coin&nbsp;&nbsp;

00:22:02.280 --> 00:22:07.880
of it landing on its edge. And even though you&nbsp;
can balance a coin on its edge, it's a common&nbsp;&nbsp;

00:22:07.880 --> 00:22:13.160
misconception that that can happen when it's&nbsp;
in motion. If you actually flip a real coin,&nbsp;&nbsp;

00:22:13.160 --> 00:22:18.560
it lands on a physical surface. It will&nbsp;
never land on its edge. And to prove why&nbsp;&nbsp;

00:22:18.560 --> 00:22:23.480
that's impossible, you need some very nice&nbsp;
mathematics, some interesting physics,&nbsp;&nbsp;

00:22:23.480 --> 00:22:29.280
and some things you might not know. The first&nbsp;
step, however, is just to actually flip a coin and&nbsp;&nbsp;

00:22:29.280 --> 00:22:38.800
take a close look at what happens. If you watch&nbsp;
what actually happens when you what? Oh, come on.

00:22:41.720 --> 00:22:46.840
Okay. Okay. All right. Okay. About about the&nbsp;
collaboration. I got it. It landed on its edge.&nbsp;&nbsp;

00:22:47.840 --> 00:22:51.560
No, you didn't. No. Seriously. Seriously. I&nbsp;
flipped it. That's not possible. First take&nbsp;&nbsp;

00:22:51.560 --> 00:22:56.880
I landed on its edge. Is we pro? We No, I know. I&nbsp;
know. I know what we proved, but I'm just saying&nbsp;&nbsp;

00:22:56.880 --> 00:23:01.480
it happened. Do it again. There's no Look,&nbsp;
there's no way. What? You You show me then.

00:23:07.120 --> 00:23:12.600
See? No. Yes. Wait. No. Yeah. I don't&nbsp;
care what your physics says. It can't&nbsp;&nbsp;

00:23:12.600 --> 00:23:16.080
happen. I know. I know. But I did&nbsp;
it again and it's bang on the edge.&nbsp;&nbsp;

00:23:17.960 --> 00:23:21.320
Okay. You're kind of the worst&nbsp;
time. It's ended on the edge.&nbsp;&nbsp;

00:23:23.200 --> 00:23:27.960
I've got some terrible news about our collab.&nbsp;
[laughter] It's been literally minutes.

00:23:32.000 --> 00:23:32.560
See you later.

00:23:38.960 --> 00:23:45.320
Yes, Steve Mold and Tom Scott did stand around&nbsp;
waiting for as long as it took for me to get that&nbsp;&nbsp;

00:23:45.320 --> 00:23:51.280
coin to land on an edge. Absolute legends. Sorry&nbsp;
it took me 8 years to get it out, folks. Uh but&nbsp;&nbsp;

00:23:51.280 --> 00:23:59.160
here we are. And now back to Modern Matt for the&nbsp;
final wrap-up. And we're done. Ah, it's so great.&nbsp;&nbsp;

00:23:59.160 --> 00:24:08.320
2026 literally 26 in the digits of pi. So write&nbsp;
that down for the next 12 months. Pi equ= 3.2266.&nbsp;&nbsp;

00:24:08.320 --> 00:24:14.440
Ah, fantastic. Now, some updates for the people&nbsp;
who watch right till the end of the video. Yes,&nbsp;&nbsp;

00:24:14.440 --> 00:24:20.360
we will do pi by hand again. We've done some&nbsp;
testing. We got a new method. We've done a bunch&nbsp;&nbsp;

00:24:20.360 --> 00:24:25.840
of research. We got a whole team on it. It's going&nbsp;
to take it's going to take so many people for so&nbsp;&nbsp;

00:24:25.840 --> 00:24:31.440
long. I'm going to need so many volunteers that&nbsp;
are all prepared to sit there for a while. And we&nbsp;&nbsp;

00:24:31.440 --> 00:24:36.120
haven't really got a plan for that. We're trying&nbsp;
to work out the best way to do it. If Moonpie is&nbsp;&nbsp;

00:24:36.120 --> 00:24:41.600
a success on the first launch, the leftover&nbsp;
funding from that will go into Pi by hand,&nbsp;&nbsp;

00:24:41.600 --> 00:24:47.320
which means we can probably do it at the scale&nbsp;
it requires. I promise I will give you at least&nbsp;&nbsp;

00:24:47.320 --> 00:24:52.520
12 [music] months warning if you want to come&nbsp;
along and be part of the pie by hand calculation.&nbsp;&nbsp;

00:24:52.520 --> 00:24:56.920
Link in the description for the sign up form.&nbsp;
I will keep you in the loop and I will tell you&nbsp;&nbsp;

00:24:56.920 --> 00:25:01.920
more than a year in advance when we're going to&nbsp;
attempt it. So don't panic. You will be there.&nbsp;&nbsp;

00:25:01.920 --> 00:25:08.040
Moonpie, the update is out. That's a lot of fun.&nbsp;
Go check it out. Link to it below. Hopefully we&nbsp;&nbsp;

00:25:08.040 --> 00:25:14.640
will launch um at some point this year. Um we'll&nbsp;
see what happens. Uh and [music] just in general,&nbsp;&nbsp;

00:25:15.200 --> 00:25:19.680
thanks for watching the videos. Oh my goodness.&nbsp;
This is a wonderful tradition calculating pie.&nbsp;&nbsp;

00:25:19.680 --> 00:25:25.520
And I couldn't have done it without Passmat.&nbsp;
Big thanks to Passmat. Um thanks to Sophie Mlan&nbsp;&nbsp;

00:25:25.520 --> 00:25:31.480
for all things Catalan numbers. Jim Prop for&nbsp;
discovering this ridiculous thing. I'll check out&nbsp;&nbsp;

00:25:31.480 --> 00:25:36.360
uh I'll link his blog post. You should check that&nbsp;
out. Uh, and of course, Steve Mold Tom Scott for&nbsp;&nbsp;

00:25:36.360 --> 00:25:43.040
for waiting for a ridiculous amount of time for&nbsp;
a dumb joke that I didn't release for 8 years.&nbsp;&nbsp;

00:25:43.040 --> 00:25:49.680
That's a pretty accurate representation of what&nbsp;
it's like um to be friends with me. Um, so that's&nbsp;&nbsp;

00:25:49.680 --> 00:25:54.080
it. Thanks. Thanks for supporting the videos.&nbsp;
Thanks for everyone on Patreon. Uh, you know,&nbsp;&nbsp;

00:25:54.080 --> 00:25:59.640
I feel like Pi Day is like uh end of one year.&nbsp;
You know, you get like financial years and school&nbsp;&nbsp;

00:25:59.640 --> 00:26:07.960
years. I run on pi years. So, that was the end of&nbsp;
the 2025 2026 Pi Day season and now we're going to&nbsp;&nbsp;

00:26:07.960 --> 00:26:14.520
go uh into the next one. And so, um that's it. So,&nbsp;
I guess we don't need this coin until next time.

00:26:22.600 --> 00:26:29.120
Oh, no. [laughter] Oh. Oh, that's so unfair.

