I want to tell you one of my favorite mathematical stories this story goes back to World War II and Nazi Germany they've got loads of Tanks oh so many tanks all over the world the Allies don't like this too many tanks the Allies want to know how many tanks the Germans are making right so the spies go out they have a bit of a spy they come back they say we reckon that the Germans are making like 1,500 tanks a month that's a lot of Tanks so the mathematicians say that is a lot of Tanks
hang on though those tanks have serial numbers so they have serial numbers on like the body of the tank and on the gun and on the wheels and on the gearbox the gearbox was best cuz the gearbox was literally just the numbers 1 2 3 4 5 6 7 in order so they said okay every time you see a tank if you capture a tank whatever write down those serial numbers send them to us we're going to do some maths on it we're going to try and estimate how many tanks the Germans are making so
that's what happened so they wrote down these serial numbers sent them back and the mathematician said we've done the maths we reckon that the Germans are making 246 tanks a month which is a big difference from what the spies were saying Well turns out that after the war the Allies can go into those tank making factories pull the records they can find out exactly how many tanks the Germans were making so they did that and they discovered that the Germans were making 245 tanks a month the mathematicians were one tank off it's a great story
it's mostly true I'm going to do some actually as we go along so I've got I've got this some tank is that a German tank or that is a German tank yes all right I got it a German tank here it is and it's got a serial number it's number one and I've got bag of tanks a bag of Tanks we've got a bag of Tanks we're going to try and work out how many tanks are in this bag all right so number one can go in here we're going to randomize it some information though
you can see the size of the bag so I don't know if that helps Brady do you want to have a wild guess without any information can I so I can't feel the weight I no I'm not going to I'm going to not let you feel the weight of the bag I'm going to guess that there are 38 38 okay we're going to see right we're going to see how close you get to 38 we'll compare it with the maths here's the thing we're doing a probability demo if it goes wrong I'll just roll with
it we'll see what happens all right we're going to pull out some randomized tanks Brady do you want to pull out a tank from my bag all right this is going to give me more of a clue now but it's too late for my okay uh all right random tank is 23 23 I like it I've got tank 15 I've got 16 16 interesting all right I will do one uh oh I've got tank one one he's back and you want to do one more one more uh 30 oh tank 30 all right so yeah
let's see given this information do you want to revise your guess no no happy with 3 and why are you happy with 38 why do you think 38 still feels good because we haven't gone over 38 yeah yeah I agree so we have got we've got some single numbers we've got some teens we got some 20s we've got something in the 30s we we've got nothing in the 40s so you're feeling good about your choice all right so we'll see what the math says and then we'll see what the actual answer was okay let's say
n is the total number of tanks in my bag I'm going to take the maximum observed number which happens to be 30 and I'm going to add on something I'm going to add on a fraction which is going to be the maximum minus K that's how many observations we made we made five observations divided by K so if we put the numbers in so 30 + 30 - 5 over 5 so it's going to be what 30 + 25 over 5 35 so 35 you said 38 so we're we're in the same area Okay so
that's my mathematical prediction now we want to know what the true answer I actually might tell you how this we got this Formula First build up the Drama All right so let's find out where this came from I'm going to draw a number line first of all there we go number one number 15 there he is number 16 23 and there's number 30 right these are the tanks that we've observed so we know that there's going to be 30 or more tanks you might be justified saying 30 as your guest by the way uh there
is actually a justification for that cuz it actually maximizes the probability what's the probability of picking these numbers from a bag probability what did I pick one 15 16 23 and 30 okay so the probability of picking what did we pick out first anyway it was 23 so that' be 1 /n if n is our number of tanks in our bag and then probability of picking the next tank would have been 1 over nus one cuz we picked out one of the tanks we got n minus one tanks left then the next observation would have
been n - 2 then 1 / N - 3 and then * 1 / N - 4 and if we don't care about the order well there's 120 ways you could arrange those if you want to work out that probability you could multiply by 120 if I want to make this observation as likely as possible that means I want to make it as big as possible I want to maximize that probability I'm going to choose the value n that is as small as possible because that will make my probability as big as possible in this
case we know it's 30 or bigger so that's the justification so you might say my guess is 30 because it makes the probability of the observation as big as possible that's the advantage the disadvantage is that's number is always going to be on the small end because if you repeat this experiment then the maximum observation is always going to be less than the true number so that's one thing you could do but maybe there's a better way of doing it all right so let's look at this number line again and if everything is equal and
random then the Gap below my minimum observation should be about the same as the Gap above my maximum observation now I did say we were doing a demo and probability demos can go wrong we actually picked out number one here yeah ideally what I want in my demo is for us to have a gap like here underneath our minimum observation so like five or six would have been yeah like like a yeah like a five or a six been nicer for this demo let's pretend we picked out five cuz that's likely isn't it then we
would have had a gap underneath tank number five and like I said if everything's fair and everything's random as it should be we would have expected a similar Gap to be above the maximum observation it's like you take that number line and just like reverse it so the role of the total number of tanks and the role of one sort of swap over and the maximum observation and the minimum observation kind of swop rolls so if I had had five there would have been a gap of say four underneath yeah and then I would have
been justified in saying well if everything's fair I might expect a gap of four to be above my maximum observation which would have been given me 34 in this case though we'll have to say I got one here so maybe then my observation here is I've got no Gap here so maybe my prediction should have be 30 okay oh happens to agree with my maximum if I repeat this experiment that's not going to be typical the advantage of it is that sometimes your answer or your guess is going to be a bit too big than
the True Value sometimes it's going to be a bit smaller than the True Value and if you repeat the experiment on average you actually get the True Value actually gets better if you repeated the experiment although you're going to get sort of a wild range of answers because it all depends on that first Gap sometimes that first Gap could be really small which actually happened when we p out number one here and sometimes it could be huge just by fluke could we s of minimize that range a little bit we could we could take the
average Gap let's do it for the actual one I've got it's the same idea between 1 and 15 so that is a gap of 13 and that there is a gap of zero cuz those are consecutive numbers then between the 16 and the 23 is uh six my next Gap here is between 23 and 30 30 so that's a gap of six I'm going to take this as my guess which is n total number of Tanks I'm going to say it's the maximum plus the average Gap maximum is 30 what's my average Gap here I've
got 13 plus a 0 plus a 6 plus a six here oh I suppose I've got a zero here as well if that had not been a one yeah there would have been a gap there as well okay so let's work that out and then let's divide by five we got five possible gaps turns out to be 30 plus if I add that up 25 over 5 hang on that's what I started with uh yes 35 the formula I started with was just another way of saying maximum plus the average Gap and that's where it
came from do you want to know now what the true value was in the bag yeah so uh so the total number of tanks in the bag was 30 so I don't know this is I feel this is pretty good cuz this is like it was 30 yeah so we pulled out one we pulled out the the bottom and the top I've got to say this haven't I I am so annoyed so now now rewind and have a look at how annoyed my face was when we pulled out one and when we pulled out 30
which is exactly the two tanks I did not want to pull out in order to show you how this works all right right the worst possible demo we could have done but these things happen because it's probability should we do one more demo uh yeah let's do this again hey Brady I've got a really good story to tell no no no no we're going to just let's two and there's another two and there's one this time we have three 10 mhm 15 18 and 24 oh if only we had pulled that out the first time
maximum observation was 24 plus and then let's do 24 - 5 over 5 24 + 19 over 5 which is going to be 3.8 which is 27.8 so 28 is two away so that's like less than 10% our first go which was 35 was like I don't know 12% away something like that hey that's pretty good 10% away much better than being 500% away which is what the spies were in This World War II story we can improve this if we repeat the experiment if we took the average of our estimates that's actually going to
get better so we've done it twice so we've got 28 we've got 35 just take the average of that I think that's going be 31 A2 brilliant even better we could make it better if we just pulled out more tanks from the bag make more observations there are ways to make this better but I thought that was pretty good already I feel like a problem that you have with the real world example with the tanks you're much more likely to get tank number one cuz it was being used on day one of the war but
tank number 20,000 didn't roll off the production line until four or 5 years into the so you're less likely to capture that tank fair enough so what I've shown you is sort of the idea if you just do the numbers 1 2 3 4 5 6 so actually this was happening monthly so on the tanks they were stamped with a month and then the serial number of that month and there's a reason why you have serial numbers on the tank for spare parts it's for quality control so there was a code on top of this
as well but we broke that code okay so that's that's another story all right so they broke that code and then there was the serial number too so there was some attempt to hide what was going on we wanted told us exactly is which Factory was making how many tanks so it told us which were the best factories to go and bomb so I said I might have some um Aces to add to this okay so we know this is true because this was written about in a paper just after the war so the whole
story is there lovely um they don't actually mention what method they used to estimate the number of Tanks so I showed you a few methods that they might have used I mean I hope it was the average Gap one that's the best one and the other um actually well if you look at the paper they actually give you a table of the numbers that they came up with any an example of the stuff they were doing this paper doesn't actually have any of the maths in it it was just telling the story this table here
has three months from the war we've got June 1940 June 1941 and August 1942 basically year apart and it tells us what the spies were saying so the spies were saying th000 tanks 1,550 tanks 1,550 50 tanks they were saying we've got a column here that tells you what the mathematicians were saying 169 tanks 244 tanks 327 tanks and we have a column here with the actual numbers 122 271 342 much closer to the mathematicians estimat and if you take the averages of those numbers in this table that's where I got the 246 tanks and
the 245 number for my story at the beginning but these are just three months pretty much picked up at random so it might just be a nice set of months that gave us some nice numbers or months that made the mathematicians look good and they and they left possibly it's possibly the paper doesn't do an average I've heard the story told afterwards where they say oh and on average they were really close so that's kind of an Max but the point of it is still the same which is the mathematician estimate was much closer than
the spies this is also something you can still do today so imagine you're like apple you don't want your rival companies to know how many iPhones you're selling but and this has been done if you're the Rival company or if you're just like Apple Fans you can just pick a random selection of iPhones look at the serial numbers use the German tank maths here and you can estimate how many iPhones they're selling as long as the serial numbers are done in a way that's crackable they might randomize them yeah as long as the serial numbers
are sort of increasing yeah that's what you want and when the German tanks were doing it sometimes there were gaps in the serial numbers you know so it wasn't perfect that's why I said the gearboxes were better because they were literally 1 2 3 4 5 6 7even uh but there's a little bit more finessing to do otherwise but no that's pretty much how it did it today's episode's brought to you by brilliant no matter what you're into or what level you're at brilliant is going to have an interactive and a Illuminating course just for
you today I was in their perplexing probability course and stumbled over this great little lesson about the Monty Hall problem this is really great so I hope brilliant don't get as many angry messages about Monty Hall as I do and have a look at some of this other great stuff on the site it's fun quirky smart personally I love these as little brain boosters getting me up to speed on topics I've long since forgotten from high school you can try everything on brilliant for free for a full 30 Days by going to brilliant.org snum file
there's also a link in the description and a QR code on the screen and by the way there's a great offer of 20% off an annual premium subscription by using that link check them out and do go have a look at that probability course it shows how mathematicians can save lives we're talking about one of the most famous Cipher Machines of all time is a code machine called the Enigma machine used by Nazi Germany in World War II to send secret coded messages so let me show you how this machine works let me open up
the machine so we have three things here at the top these things are called rotors