# I love it Venn a plan comes together.

Below is a Venn diagram. These are diagrams that use circles to represent sets that contain objects. In our case the circles represent two sets, one a group of high-sugar foods and the other a group of healthy foods. The rectangle around theses sets can be thought of as representing the whole universe of all possible foods (mmm…). Where the two circles overlap the sets are said to “intersect”. The mathematical way of writing that sets A and B intersect is A ∩ B. All of the objects in both sets can be written as A ∪ B, the “union” of A and B (think ‘U’ for ‘u’nion). One other useful thing to know is the “complement” of a set, A’, which just means not A.

Let’s examine the items in the intersection High sugarHealthy. I think it would be a bit extreme to claim that anything in the intersection isn’t healthy, but it’s a fact that fruits like Bananas, Grapes and Mangoes contain a lot of sugar.

So we can already see how a Venn diagram might be useful as a visual tool to make sense of the world. But are there any other uses? Well, it turns out they can be very helpful to get a handle on certain problems that human beings generally have very little intuition for. Welcome to the world of “conditional probability”, where we answer questions like “what is the probability of something happening given that another thing already happened”. What is the probability of you reading this any further, given that I have just started talking about conditional probability? Go on, keep reading. What is the probability now, given that I just encouraged you to keep reading? In the real world, many events are conditional on other events, but if they are not, they are said to be “independent” events.

Let me start with a simple example involving a pack of playing cards and a Venn diagram. There are 52 cards in a full deck, and 4 different suits: clubs, spades, diamonds and hearts. Each suit has 13 cards comprising the numbers 2 to 10 and four picture cards which are the Ace, Jack, Queen and King.

In the diagram above the yellow circle labelled A represents all of the cards which are Aces. There are four Aces, the Ace of Clubs, The Ace of Hearts, The Ace of Diamonds and The Ace of Spades. The red circle labelled B represents all of the cards which are hearts. There are 13 hearts in the whole pack of 52 cards. Only one card in the whole pack is both an Ace and a Heart and that is the intersection A ∩ B.

So I could ask the question, given that the card is a heart, what is the probability that it is an ace? Well, there are 13 hearts and only one Ace of Hearts, so the probability is 1 in 13. Can we get to this using a Venn diagram?

So “given” that we know the card is a heart, we know it is in the green circle. The green circle contains 13 items, only one of which is an Ace, the Ace of Hearts. There is a mathematical way of saying “given”, so A | B means “A given that B is true”. In the case above, A stands for “the card is an Ace”, and B is “the card is a heart”. So literally, we want to know the probability that the card is an Ace given that we know the card is a heart.

Perhaps we can now start to see the intersection of two sets in a different way. If the green circle is a given i.e. we know we have a heart, then the intersection is the only bit of the green circle that also satisfies the red circle. Therefore, the number of items in the intersection, divided by the total number of items in the green circle gives us our probability (1/13).

More generally we can write:

$P(A \vert B) = \frac{P(A \cap B)}{P(B)}$

and from this one can derive Bayes’ Theorem, the work horse of conditional probability. From this, quite surprising results can follow, like this one.

Suppose you are a famous athlete (you might be for all I know?) and to your horror you test positive for a performance enhancing drug. It’s the kind of test result that could get you banned from your sport, stop you earning a living and ruin your reputation forever. You are innocent, and you want to prove it to the world using maths…

So you do some research and find out that the test is 95% accurate at picking up the drugs when they really are in your body (a “true positive”). But you also find out that the test isn’t perfect and can sometimes get it wrong, producing a positive result even if you didn’t take any drugs (a “false positive”). However, you are a bit discouraged when you find out that the test is pretty good and a false positive result occurs only 3% of the time. The final bit of information you find out, by talking to some experts at wada and ukad, is that only 1% of all athletes take performance enhancing drugs. So what is the chance that you did take drugs, given that you tested positive??

You read up on conditional probability (you are trying to find out the chances that you took drugs given that you tested positive), you put the numbers in to Bayes’ Theorem, and you discover that there is only a 24% chance you took drugs despite the test being positive. Of course you knew you were innocent, but this is proof to the world that your innocence is more likely than your guilt. Phew! Maths has saved your career. Despite the test having a true positive rate of 95% and only predicting a false positive result 3% of the time, it is still much more likely you didn’t take drugs even though you tested positive!!  Your second sample comes back negative and, vindicated, you go on to win Olympic gold.

In the drug testing of real sportsmen and women, the tests have to be extremely accurate with very high true positive rates and very low false positive rates. Furthermore there are multiple tests to reduce the chances of false positives wrecking somebody’s career.

Advertisements

# Somewhere over the rainbow

Around this time of year, if you’re out and about, it’s easy to get caught in an unexpected “April shower”. A strong air current called the ‘Jet Stream’ about 15 km up in the sky tends to move northwards in early spring, allowing blustery winds and rain to come in from the North Atlantic.

One good thing about this is that such changeable weather produces lots of rainbows, like this one just outside our house.

So what ingredients do you need to produce a rainbow? We need sunshine from one part of the sky to shine light on raindrops in another, so that’s just two ingredients, water and light. The light bounces around inside the raindrops and comes out again, producing the rainbow that you see in the sky. The raindrops act like little prisms like the one shown below.

This all sounds really simple, but it’s actually quite complicated and involves loads of physics.

To fully understand it, we need to know that light travels in straight lines but it bends when it travels from one material to another, how it reflects, about a phenomenon called “dispersion”, another called “refraction” and that sunlight is made up of lots of different colours all mixed together!

When light travelling through the air enters a water droplet it is bent slightly. This happens because light travels at different speeds in different materials, and is known as “refraction”. Having been bent, the light travels to the back of the raindrop and some of the light bounces back off the far side of the raindrop. When it travels outwards, back in to the air, it is bent again due to refraction at the water/air boundary. So the whole path of the sunlight through the drop looks something like:

But something else is going on here too. The light is split in to all its colours because “refraction” (the amount the light gets bent) actually depends on the light’s colour. Different colours get bent or “refracted” more than others. Sunlight is also known as “white light” because it is made up of all the colours the human eye can detect, mixed together. This splitting or “dispersion” is exactly the same phenomenon that happens when people put little crystals in their windows to cast rainbows on the walls of their rooms.

Looking more closely at the bottom right of the picture above, we see the red light is on the bottom and the violet light is at the top, because the violet light gets bent more than the red. But anyone who has seen a rainbow knows that it’s always the red that’s on top! So what’s happening? Well, when we see the red and blue colours, they’re actually produced by different raindrops that fall along our line of sight.

So, in simple terms, even though the red ray is at the bottom of the top raindrop, we see it at the top of the rainbow because the violet ray from the top raindrop never reaches our eyes. Below there is another similar diagram showing the ordering of the colours in the rainbow.

The main point though is that each raindrop doesn’t produce its own rainbow; a rainbow is formed from millions of different raindrops!

If you look carefully the next time you see a rainbow, you might notice that there is a faint “secondary rainbow” on the outside of the main rainbow. Look even more closely, and you’ll notice that on this one, the red band is at the bottom! This is because the secondary rainbow is caused by light which undergoes two internal reflections inside the drop. Tracing the path of the light rays, we now see that the red light is on top!

The path of lots of (parallel) light rays from the sun hitting a single water droplet looks something like that shown below. The shape of the drop is such that the rays are concentrated at the bottom and form the primary rainbow, whilst all the others come out in other directions and mix together producing a bright area of “white light” inside the arc of the rainbow.

So next time it’s raining and you can see your shadow in front of you, look up and you might just see a rainbow. You can look to see if the bow is brighter inside and if you can see the faint secondary bow, and you’ll know why the colours of this secondary are inverted relative to the primary bow. Maybe one day you’ll even be lucky enough to see a rainbow from a plane, because then the ground won’t be in the way and you’ll be able to see the rainbow make a full circle. And to make it even more special, just consider for a second that the rainbow you see is unique to you. The bow you see is generated from a set of raindrops that lie on the surface of a cone exactly along your line of sight, so no two people see exactly the same rainbow.

# Good vibrations

A friend recently asked me to write a little piece about “why hot things melt cold things”.

There is no doubt about it, some things just don’t happen in life. If you have two cups of coffee at the same temperature, and you place the cups in contact with one another, you’ll never see one suddenly become hot whilst the other becomes cold. Scientists have made similar observations for many hundreds of years, and a whole area of physics has arisen called “thermodynamics” which tries to explain heat, energy and temperature.

Several scientists have written rules about this, such as Rudolf Clausius, who said

No process is possible whose only result is the transfer of heat from a cooler to a hotter body

(except he said it in German). You might have heard of Newton’s Laws of Motion, named after Isaac Newton who first wrote them down. Well, the statement above is another law of physics, known as the 2nd law of thermodynamics. The 2nd law describes how, when systems interact, they eventually reach a balance, or an “equilibrium” (remember I talked about equilibrium in a previous post here). So a hot cup of coffee and a cold cup of coffee will end up the same temperature when left in contact for a long period of time. The statement above is a bit more specific, and is referred to as the “Clausius statement” of the 2nd law.

What this really means is, if you want heat to travel from a cold object to a hotter object, you have to add energy to make it happen. This is why you have to plug your fridge in to the wall to make it work! The fridge takes heat from cold objects and makes them even colder, and then exhausts that heat in to the room (which is why fridges are often slightly warm to the touch, though I don’t recommend you start sticking your hand behind fridges to find out!).

ANYWAY, back to the question. Why is it that hot things melt cold things? Well, I’m going to assume we’re talking about two objects that are touching each other, so the answer is a process known as “thermal conduction” (there are two other ways heat gets transferred, “convection” in liquids and “radiation” which is how the heat gets to the Earth from the Sun, that I won’t explain right now).

Now the key thing to remember is that objects are made up of tiny little particles called atoms and molecules. These particles move about, bumping in to each other and also vibrate themselves. In fact, in hard solid objects, most of the energy is due to the vibration of molecules and these molecules are closer together than they are in liquids and gases. A molecule can vibrate over a million million times a second! Temperature is really just a way of measuring how much energy all these little particles have. When a substance gets hot, it has more energy, so its atoms and molecules vibrate more quickly. These vibrations make other nearby atoms and molecules vibrate too (try holding on to the washing machine when it’s spinning and see if you can stay still!). This process happens really efficiently in metals, because electrons in metals can move about more freely and transfer this energy to other parts of the metal. If you leave a spoon in a mug of tea, it gets almost too hot to pick up because the electrons efficiently transfer the heat along the length of the spoon.

So this is why hot objects melt cold objects. It’s because the energetic particles in the hot object are buzzing and vibrating, and this, in turn, makes the molecules on the surface of the colder object buzz and vibrate too. These vibrations spread from molecule to molecule, heating up the colder object and cooling down the hotter object. We measure these changes in energy as temperature. The moral of the story is, don’t (like I did) leave a pile of Christmas chocolates on top of the microwave…

# We’re all under pressure…

My young lad asked his Mum a very interesting question the other day:

Why doesn’t all the air just fall to the earth if gravity is pulling on it?

It’s a perfectly sensible question. Why isn’t the Earth’s atmosphere smeared out in a dense thin layer right near the surface? To understand why, we need to explain a few things about air, how it gives rise to something called ‘pressure’ and I should probably explain, as part of the process, what I meant above when I used the word ‘dense’.

What is air, or rather, what is our atmosphere? It’s a mixture of gases surrounding the Earth, about 78% Nitrogen, 21% Oxygen and 1% Argon (as well as tiny amounts of other things like Carbon Dioxide, water vapour and old space junk etc). Now compared to the size of the whole earth, the atmosphere is very thin indeed. Despite appearances, it still weighs about 5 billion billion kilograms (5,000,000,000,000,000,000). When you lie outside on the grass and look up, you are looking up through a vast column of air that the Earth is pulling downwards. The molecules that make up the gases in the air aren’t stationary, however. Quite the opposite in fact, they are flying around at great speed bouncing off each other. Using some simple physics you can show, roughly, that air molecules at room temperature are moving around at about 500 metres per second, that’s over 1100 miles per hour. To provide some context, the typical cruising speed of a commercial passenger aircraft is about 550 miles per hour! As the molecules move around they bump in to things (and each other) exerting a force. Imagine blowing up a balloon. The air pressure that is caused by the motion of the air molecules bouncing against the insides of the rubber balloon make it inflate. You might remember, this is also related to an earlier post I made about the mechanical equivalent of heat. The hotter air gets, the faster the molecules move about – heat is motion.

Now, when gravity pulls down on the atmosphere surrounding the earth, it doesn’t pull all the air in to a very thin layer because of this “air pressure”. It does compress it, however. At the surface of the Earth, the weight of the atmosphere pressing down from above does push the molecules closer together. Another way of saying this is that air near the surface is more ‘dense’; the air contains more molecules in a given volume at the surface than it does 100 km up in the atmosphere as there is less air above pushing down when you’re so high up. There is a balance struck between gravity pulling down and air pressure resisting that downward pull known as “hydrostatic equilibrium”. An equilibrium describes a situation where opposite forces balance one another. It’s a similar situation in stars whose huge gravitational pull far exceeds that of the Earth. In that situation the outward pressure from the nuclear reactions inside the star balance the massive inward pull of gravity.

We can visualise how the number of molecules in a given volume of air increases as we get closer to the surface using the simple picture below.

The density of the air is shown here in red. As we get closer to the surface, the air gets more dense (the molecules are closer together so the red colour becomes more concentrated) due to the weight of all the air above. Looking at the mountain in the picture made me think of something else too. All the weight of a large mountain pressing down on the rock at the bottom of the mountain places a limit on how big it can get. If it got too big, the huge pressures would turn the rock in to a fluid-like state which would flow out causing the mountain to shrink. This is why the mountains on Mars can grow taller than those on Earth, since the acceleration due to gravity on Mars is much lower (about 38% that of Earth). Olympus Mons is over twice the height of Mount Everest!

Now this is probably way too complicated for my intended audience, but I can’t resist going in to a little bit of physics. We can actually analyse the forces (the pushes and pulls) on a small volume of air in the Earth’s atmosphere and get a better picture of how the forces balance one another.

I’ve picked out a small volume of air in the atmosphere. The surrounding air pushes from all directions so we have the air being squashed from the top and from the bottom. The force due to the push from the top is the pressure multiplied by the area i.e. Force = Pressure x Area. Similarly we have an upward pressure from the bottom, but these two don’t quite cancel out because they are at different heights. Since we assume that this tiny block of air as a whole isn’t moving (it is in equilibrium) the forces balance i.e. add up to zero. In the picture above, the term $\rho A h g$ is the force due to gravity. This is the volume, $A \times h$, multiplied by the density, $\rho$, multiplied by g, the acceleration due to gravity. You’ll notice a lot of Greek symbols get used in physics and maths, and this one, $\rho$, is called ‘Rho’ (pronounced like ‘row’ a boat!). If you ever look at a list of all the different physical constants found in physics, you soon run out of letters from the alphabet very quickly, so we have to borrow from the Greek alphabet too.  A physical constant is a quantity that is always thought to remain the same throughout time anywhere in the Universe. Examples are the speed  of light in a vacuum or the charge carried by a proton. Actually, having given those two examples, I now realise both of those physical constants use letters from the normal alphabet, ‘c’ for the speed of light in a vacuum and ‘e’ for the proton charge! Oh well.

So  we can express the difference in pressure as a function of the height, the acceleration due to gravity and the density of the air. Now, as already discussed, the density will vary with height, but if we assume close to the earth that the density of air is about 1.2 kg per cubic metre, then for every 1000m in height the pressure changes by about 11760 Pascals (11.76 kiloPascals). If we use the laws of thermodynamics, one can show relatively simply that the temperature of air (under certain conditions I won’t go in to!) decreases by about 9 degrees celsius for every km increase height. This is known as the “dry adiabatic lapse rate”, for those interested. You can understand this in terms of the air expanding as it rises, since the pressure is lower. As it expands it has to push against the air molecules around it, so it loses energy and its temperature therefore drops (by about 9 degrees celsius per km).

A couple of years ago I was fortunate enough to climb Mount Kilimanjaro with my Brother. When at the top, some 5895 metres above sea level, I can indeed verify that it was perishingly cold, and the air was very thin making it hard to breathe after a small physical effort.

# Pythagoras

My daughter asked me what Pythagoras’ Theorem was…

This theorem describes the relationship between the three sides of a right angled triangle. In words, it says the squared length of the two shorter sides is equal to the squared length of the longer side. What do I mean by a “squared” length? It’s just the length multiplied by itself, which can be drawn like a square, since the area of a square is exactly that. So the square of 2 is 2 x 2 = 4, or the square of 5 is 5×5 = 25. A squared number can be written using a special mathematical notation. Notice how the 2 is raised higher than the 5, and this means “5 squared”:

$\textrm{The square of 5} = 5^2 = 25$

As a formula, Pythagoras’ Theorem can be written:

$a^2 + b^2 = c^2$

where ‘a’ and ‘b’ are the two shorter sides, and c is the longer side (called the hypotenuse).

I can try and show this using the picture below. Since a squared number is the same as the area of a square, I can draw the squares next to the sides of the triangle. Then the area of the two smaller squares, according to Pythagoras’ Theorem, is equal to the area of the biggest square. By splitting the smaller squares up, we can see they fit perfectly in to the bigger square in the animation below.

Now if we wanted to find the length of the hypotenuse (the longest side) when we knew the length of the other two sides, we would have to use the following formula:

$c = \sqrt{a^2+b^2}$

The symbol in the formula above is a square-root sign. The square root of a number is another number which you have to multiply by itself to get the number you started with! So using actual numbers instead of the complicated definition above, the square-root of 9 would be 3, since you have to multiply 3 by 3 to get 9. Similarly, the square-root of 16 is 4 and the square-root of 25 is 5.

So if we knew that the two shorter sides were 3cm and 4cm, then the length of the longest side (the hypotenuse) would be:

$c = \sqrt{3^2+4^2} = \sqrt{9+16} = \sqrt{25} = 5$

This is actually known as the 3, 4, 5 rule, and carpenters can use it to make sure they create perfect right angles when building things!

# In hot water

I don’t mean to start blog posts with idioms, but I’m already struggling to find titles and this is only my fourth blog post of all time.

The other night, my wife boiled the kettle for her hot-water bottle. It wasn’t particularly cold, probably 6-7 degrees outside, but certainly a crisp clear February night. It occurred to me how little effort it took, to flick a switch, wait a minute and have a litre of boiling hot water. How much effort would it take me I wondered, if I had to boil that using mechanical energy? I have one of those indoor water rowers with a rotating paddle inside. I’ve been on that for hours, and the water hasn’t heated up much.

Well, it turns out that back in 1798, a scientist named Benjamin Thomson did an experiment in which he boiled water from the heat generated by boring a cannon (boring a cannon is the process by which a hole is drilled in to the brass). It took him two and a half hours, but there it was, heat with no fire. This was the birth of thermodynamics, a new branch of physics which established an equivalence between mechanical work and heat.

Another physicist called James Joule conducted an experiment in which he heated water using this apparatus. The ‘work’ done by the falling weight heated the water. In 1845 he published a paper called “The Mechanical Equivalent Of Heat” in which he worked out the amount of frictional heat required to raise the temperature of a pound of water by 1 degree Fahrenheit. The unit of energy became named after Joule, and today it is established that it takes about 4.2 Joules to raise 1 gram of water by 1 degree celcius. This quantity is known as the ‘specific heat of water’.

Now back to my 1 litre of water. 1 litre of water is 1000 grams, and tap water is probably about 10 degrees celcius. So to raise 1000 grams of water by 90 degrees (up to 100 degrees celcius which is boiling point of water), we need to add about 4.2*1000*90 = 378,000 Joules of energy.

So if I were to build an experiment like Joule did, run to the top of a cliff, attach a rope around my waist to a rotating paddle inside my perfectly insulated one litre flask, how far would I have to fall before my tap water water had begun to boil? Well using a simple physics equation for work we can solve for the distance:

$\textrm{Work} = \textrm{Force} \times \textrm{Distance}$

so

$\textrm{Distance} = \frac{\textrm{Work}}{\textrm{Force}}$

and Isaac Newton reminds us

$\textrm{Force} = \textrm{Mass} \times \textrm{Acceleration due to gravity}$

so finally, given the Work we need is 378,000 Joules and I weigh about 65KG

$\textrm{Distance} = \frac{378000}{65 \times 9.8} = 593~metres$

It would be, assuming all of the mechanical energy was perfectly converted in to heat, about 600 metres. It would not be nearly so efficient, so lets just say despite our best efforts, allowing for some imperfections in the conversion of mechanical energy to heat energy, about 1 km. That’s like jumping from the top of Scaffel Pike. Or suppose I wanted to use my rowing machine. According to this handy calculator, if I row at a leisurely 2 mins 15 seconds per 500m I’ll generate about 140 watts (1 watt is 1 Joule per second). So that means with 100% efficiency, and a perfectly insulated container, I would have to row for about 45 minutes. My rowing machine holds about 20 litres of water, so I’d need to keep it up for 900 minutes (15 hours) to boil the lot.

So next time you boil the kettle, you might want to think about whether it’s really that cold outside to warrant a hot-water bottle. It’s a lot of energy isn’t it?

# What are the odds?

I went to visit my parents this weekend, and whilst in the car my son asked me what the funny numbers meant on an article I’d passed to him on my phone. The article was about the new Mercedes W07 which has been unveiled for the 2016 Formula 1 season. Embedded within the article was an advert from a well-known betting company. The funny numbers were odds. The proper name is actually ‘fractional odds’ because they are expressed as fractions like 3/1 (3 to 1) or 4/1 (4 to 1).

The next 30 minutes of the journey flew by, whilst I explained to him how odds work. They suggested I should write out a proper explanation on my blog, so here goes.

In simple terms, the odds of an event tell us how likely it is. The larger the odds, the less likely it is to happen; there is a direct link between the odds and the probability. If the odds of Jenson Button winning the 2016 Formula 1 World Championship are 40 to 1, then it is considered that the chances of him going on to win are far smaller than Nico Rosberg’s chances, who has odds of, say,  3 to 1.

We can understand what odds mean by thinking about how much money we would get back when we make a bet, compared to what we put on. So for odds of 3 to 1, think of the last number as the amount we bet, and the first number as what we would get back if we won that bet. So suppose the odds of Leicester winning the league were 3 to 1, then if we put £1 on Leicester winning the league, we would get £3 back. Actually we would also get our original £1 back too, but that isn’t included in these type of ‘fractional’ odds (it is in decimal odds but that’s over-complicating things). We don’t just have to bet £1 though; if we bet £10 then we would win £30, so we win £3 for every £1 we bet (and if we win, we get our original bet amount back too, which is called our stake).

Now, actually, at the start of the football season the odds of Leicester winning the premiership were 5000 to 1! So a £5 pre-season bet would return £25,000 if Leicester did win the premiership. Sometimes, the people who set these odds (called bookmakers) get the odds very wrong. I’m a big boxing fan, and two fights that come immediately to memory are Tyson Fury vs Wladimir Klitschko and Manny Pacquiao vs Oscar De La Hoya. The bookmakers got those odds completely wrong, and this writer remembers that fact extremely well!

The link between the probability of the event happening and the fractional odds of the event can be expressed using a mathematical formula:

$\textrm{Probability} = \frac{1}{1+\textrm{Odds}}$

So if the odds against an event happening are 4 to 1, then inserting 4 in to the formula above gives:

$\textrm{Probability} = \frac{1}{1+4} = \frac{1}{5}=0.2~\textrm{or}~20\%$

Another way to think about those odds (of 4 to 1), is to say if the event (e.g. a Formula 1 racing season, or a football match) was repeated 5 times, that outcome is likely to happen only once. So it happens 1 out of 5 times, and doesn’t happen 4 out of 5 times. This is why the proper name for these type of odds is ‘the odds against’.

So let’s try a more complicated example. The odds for Lewis Hamilton to win the Formula 1 World Championship in the 2016-2017 season are about 8/13. So this means for every £13 we bet, we get £8 back. That means the bookmakers think this is quite a likely scenario, so they aren’t willing to give very high odds, in case they lose too much money! So just how likely is it? Inserting the odds in to our formula, we get:

$\textrm{Probability} = \frac{1}{1+\frac{8}{13}} = \frac{1}{\frac{13}{13}+\frac{8}{13}}=\frac{1}{\frac{21}{13}}=\frac{13}{21}=0.62~\textrm{or}~62\%$

So in ten repeats of next season, the bookmakers think that Lewis Hamilton would win about 6 out of 10 times. Do you agree?

If you didn’t agree, perhaps because you have created a more accurate model of the future than the bookmakers, then you would have what is called an ‘edge’. With that edge, you could then bet using a formula called The Kelly Citerion, which tells you the best fraction of your money to place on each bet.

$\textrm{Kelly Fraction} = \frac{bp-q}{b}$

In the above formula, b is the odds received on the bet (so 4 if the odds are 4 to 1), p is the probability of winning the bet (according to your superior model) and q is the chance of losing the bet (which is the same as 1-p).

So supposing you had written a complicated mathematical model which incorporated lots of data and you had been able to show that this was more accurate than the bookmaker’s models (that is actually the really tricky bit). You disagree with their 8/13 odds on Lewis Hamilton, and your model predicts a larger probability of 80% that he will win. How much should you bet? Well, using the formula, the Kelly fraction would be:

$\textrm{Kelly Fraction} = \frac{\left(\frac{8}{13}\times0.8\right)-0.2}{\frac{8}{13}}=0.475~\textrm{or}~47.5\%$

So you should bet 47.5% of your wealth! So if you had £100 you should bet £47.50. The reason you should bet this much is because the odds the bookmaker is offering are actually higher than they should be, as they don’t realise how likely the event is (assuming your model is a more accurate reflection of future events).

And now comes the cautionary tale. Bookmakers spend huge amounts of money filling offices full of very clever people to build models to predict the outcomes of sporting events. The chances of you ever producing a superior model are very small, so unless you know a sport very well I wouldn’t waste your money betting, ever.

Much better to take your money when you are very young and invest it. The power of compound interest will work in your favour, but perhaps that should be a separate blog post for the future!