thank you to all of you for coming along now as Tom mentioned I'm researcher the lung School of Hygiene Tropical Medicine where I specialized in mathematical models of infectious disease so on the face of it my job couldn't be further really from the world of casinos and playing cards and plastic chips but really science and gambling have an incredibly intertwined relationship every long-standing history and that's what I want to talk about this evening and seeing as I'm talking about gambling I thought I would start with an example of how not to gamble so this is a story story for a few years ago and as you can pull notice there's two large floors with this lady strategy how the first is it's completely illegal the second is it clearly doesn't work and the reason I want to show you this is I think when we talk about people taming chance and eating the system typically these are two themes that crop up quite a lot you either have them doing something a bit dodgy or you have them presenting a system which clearly isn't going to do something very successful and what I want to do this evening is take a look at a third approach take a look at some of the ways in which mathematicians and scientists have taken on games of chance and use their techniques to get an edge over the house I also want to look at how the idea to flow the other way how actually games and gambling have inspired many ideas which are now fundamental to modern math and science and really lotteries I think a good place to start because for me it was a story about lotteries that first got me interested in the mathematics of betting as I'm sure any of you who've played lottery or thought about playing lottery will know it's incredibly difficult to win even the way we measure how difficult it is to win is a fairly recent development although maths is it's been around for millennia the idea of how we quantify luck how we quantify a random event is a relatively recent one it was one that was developed in the 16th century in Renaissance Italy there was a Italian called Joel amo Cardno he was a physician as a doctor he was the first to describe the clinical symptoms of typhoid he was also a gambler and as a gambler he was the first to describe such games mathematically he actually outlined what's known as the sample space so this is the all of the combinations of events that could occur and obviously if you're only interested in one of those that gives you a sense of how difficult it is to win now for the UK National Lottery as it stands you have to pick six numbers from a possible set of 59 so this results in just over 45 million possible combinations of U of numbers you could pick if you bought a card okay that makes life a difficult for you to win the jackpot but there is a way you can guarantee you will win the lottery that like this weekend and that is quite simply to buy up every single combination of numbers now that might sound a little bit absurd but let's just just run with it for a moment um as I said there's 45 million combinations of tickets for the UK lottery so if you were to buy up every single possible combination and line them up end-to-end it will actually stretch from London to Dubai what's more each ticket costs 2 pounds so if you really want to win the jackpot this weekend it's going to cost about 90 million pounds to achieve clearly that's not a feasible strategy but not all lotteries are the same in the 1990s for example with the Irish that philosophy had a much smaller sample specs much smaller possible combination of numbers that could come up in fact there were about 1.9 4 million combinations each ticket costs 50 P so as a result it would cost you less than a million pounds to buy up every single combination and actually a syndicate headed up by an accountant got thinking about this and it's clearly in most weeks this is a pretty poor investment because the jackpot would be maybe a few hundred thousand and if you're spending almost a million to win a few hundred thousand doesn't say much to spot that's a pretty bad investment but if a rollover were to come around yeah maybe this could be plausible and actually rather than stretching to Dubai if you lined up all of these tickets and the combinations end-to-end would actually stretch from London to Plymouth so yeah you've got something that's a bit more doable and what I started to do is to collect together these tickets and fill each one out I hand to get every single one of these combinations and then they waited they worked for about six months until the may bank holiday in 1992 when the rollover hit 2.2 million and they put their plan into action they took all these tickets they'd filled out start taking the shops and buying them up and in many cases this raised some attention so shops would usually sell maybe a thousand tickets in a week where suddenly selling 15,000 the lottery yeah perhaps expectedly found upon this a little bit and tried to stop them and as a result when the lottery draw came around they'd only bought 80% of the possible combinations of tickets so still an element of luck as to whether they win the jackpot fortunately for them that's jackpot winning certain numbers was within the combinations they're bought up so they won that week unfortunately there were two other winners that week so they had to split the jackpot but when you added up all those lower-tier prizes that they matched up five numbers four numbers as well they walked away with a profit of 300 thousand pounds now for me here's you're going to heard the story that was just a fantastic illustration of how you can take a pretty simple mathematical insight a good dose of audacity and hard work and convert it into something that's profitable and yeah this isn't the only instance that people have targeted these kind of games for the UK lottery the draw is random so really the only way you can guarantee a win its use this brute force approach by simply buying up all of the combinations but not all lotteries are the same take scratchcards for example on the face of it scratch cards are completely random if you kind of think about it they can't be completely random because if you're producing scratch cards and you just randomly generates which cards are going to be winners there's a chance that by sheer chance you will produce too many winning cards if you're a company making scratch cards you want some way of controlling and limiting which prizes go out as stat systems we call it you need controlled randomness you want the prizes to be fairly uniformly evenly distributed amongst locations but you don't want the generation that's be completely random and actually in 2003 isatis wrinkled meringue serve answer was thinking about Stratos he'd been given some as a joke present and was wandering outside of controlled randomness he realized there must be some way for the lottery to I IFI which cars winners without having to scratch them off on each card there were a series of digits and some of these would appear two times three times but some numbers and symbols only appeared once on the card and actually if these unique numbers appeared in a row that card was always a winner and you went it bought more cards and tested out in strategy and every single time the cars that had these numbers in a row were guaranteed win it now what would you do in this situation you've essentially crapped scratch cards you've got a system which can identify the winning ones and they're not winning ones just by looking at them would you go out and buy tons what do you well think back to that slide I showed you at the start winning scratch cards are remarkably rare and actually what Mohan did rather than just going on a huge scratch card buying spree was um work out how long it would take him to buy up enough cards and guarantee himself win and he was a statistician and working on geological problems earning pretty decent money and he realized actually although he had a winning lottery strategy it was better off just to stick in his existing job so what he did um when he rang up the lottery and told them that there was a hidden code on their scratch cards and he had deciphered it and he knew how to win the lottery of course didn't take him seriously so what he did was actually collected the scratch card the identify some winning ones some losing ones to vitamins to piles and posted them by courier to lottery that evening he got a phone call from lottery saying we need to have a chat and we this story it's represented a lot of areas of gambling often it's not professional gamblers you come up these strategies that beat the system and often people who beat the system don't become professional gamblers for a lot of these people gambling is almost a playground for ideas this way of testing out problem solving and skills that actually will apply to many other industries people who talked these problems moved into academia into finance into business and as I mentioned with kadhai know this isn't a new phenomenon really throughout history many of the great thinkers and mathematicians have used gambling as a way of refining their ideas in around 1900 a French mathematician called Omni prawn curry was particularly interesting gambling at panco a was one of the Watsons lost universalist as a mathematician he was gone lost people to specialize in almost every area of the subject as existed at the time I hadn't expanded to the point where it was a larger is today and one of the things he was interested in was predictability and to him unexpected events unexpected outcomes were the result of ignorance he thought if something's unexpected it's because we're ignorant of the causes and he classed his problems by what he called the three levels of ignorance the top level was a situation where we know what the rules are we have the information we'd have to do some basic calculations so if you've got say a school physics exam you know what the physic physical laws are you're given the information so you know in theory you should be able to get the right answer it's a answer surprising then you've done something wrong in the working but it's not a kind of difficult level of ignorance to escape in theory the second level of ignorance according to panco a was one where you know what the rules are but you lack the information necessary to to carry out the calculations accurately and he used roulette as an example so and we let table you started ball spinning round around and he observed a very small change in the initial speed of the ball could have a very dramatic effect on where it ends up because it's going to be circling this table over time and nowadays mathematicians refer to this as sensitive dependence on initial conditions and popularly it's known as the butterfly effect there's a talk in the 70s where a physicists point out that a butterfly flapping its wings in Brazil could cause or perhaps prevent a tornado in Texas these very small changes which Punk away first observed could have a large effect later on and then we'll say that the results is random it's down to chance but really it's a problem of information then comes the third degree of ignorance this is where we don't know the books or perhaps they're so complex we'll never be able to untangle them and in this situation all we can do is watch watch over time and try and gain some understanding of what we're observing and is really this level of ignorance when gamblers started targeting roulette that they focused on they didn't try and untangle all of these physical laws they just said well let's just watch a load of roulette spins at a table and see if there's a bias see if there's something odd going on with this table but this raises the question of what you actually mean by order what do we mean by biased and what point gray was thinking about roulette in France on the other side of the oh no a mathematician called Karl Pearson was also thinking about roulette and Pearson was fascinated by random events as he said we can't have any true sense of what nature does we can only observe and try and make inferences on those observations and he's really keen to collect random data to test out these kind of ideas on one occasion he spent its summer holiday flipping a coin in 25,000 times to generate a data sets to analytes and he was also interested in roulette now fortunately for him at the time the Lomonaco newspaper would publish the results of all new roulette spins in the casinos at Monte Carlo now for bits and this is a fantastic data set he wants to test that his ideas about randomness you've got all these previous roulette spins to test it out on and he started looking at ways to understand whether they were random or not and that table of course you've got these black and red numbers and then you've got 0 if you take out the 0 over time you'd expect the proportion of that can read to be even you'd expect it kind of be 50/50 over time and when Pearson looked at the data he found that red came up 50 point one five percent of the time this was over about 16,000 spins so according was calculation this wasn't that implausible so actually that kind of deviation from the expected value is reasonable given the kind of data set he had but then he continued and he looked for instance at how often pairs of numbers appear now if you've got a random process of roulette table sometimes you'd expect there to be a string of the same color appearing purely by chance might be a few Reds coming up a few blacks what Pearson found was that the numbers switched too often actually you didn't get the strings of the same color appearing as often as you might expect they were kind of switching over and to him this was pretty definitive evidence that the tables were corrupted low bias and as he puts it if I had been observing the table since the start of geological time on earth I would not have expected to see a result that extreme and he actually suggested that they closed down the casinos and donate the proceeds to science as it happened there was something a little bit more down-to-earth going on it turned out those journalists Philharmoniker rather than sitting by the tables and coordinate numbers instead of been sitting in the bar and making them up for this idea think back think back to how he phased it it was the probability of observing an event as extreme as one I've observed this was that the first kind of four is into what those hypothesis testing nowadays you know whether we work in clinical trials or on particle physics experiments we use the principles that Pearson honed on these roulette tables and acquaintances to understand whether we have enough evidence to reject or accept a certain hypothesis so in this cases hypothesis what the tables were random and you had enough evidence to say that it wasn't the case and actually gamblers who also use these ideas throughout Victorian times and moving into certain late 1940s for example to medical students are used these kind of methods to go and unlike the lazy journalists they actually watch the tables this time collected all the data and found that their biases these tables wore down over time and certain numbers or areas would appear more often for naught and actually they went round the vada and gambled a lot these tables and exact figure was never known but they did buy a yacht and sail around the Caribbean for year so a pretty successful strategy the problem for gamblers those casinos kind of cottoned on to what they were doing and they would make sure the tables were incredibly well maintained and you didn't have these biases occurring but in the 60s and 70s some physics students realized that this actually leaves you in the second level of ignorance because if you've got a very pristine well maintained roulette table it's not a statistics problem it's a physics one as one of them said it's it's kind of having a planet orbiting a point you gots ball going round and the seventy is a group of students at University of California Santa Cruz actually kind of started doing these calculations and they looked at roulette spin they said well to start off with the croupier will spin the ball and it would go around the edge of the track around the rim of the table and often it will go around a couple of times before the croupier calls no more bets so in other words you have a window in which you can collect information what the balls doing and act on it you can place bets during this period over time it would drop down onto the track and this will spin freely they mentally hit on these deflectors and land in one of the pockets and what's it that he did testing out their strategy on different tables in their lab was realized that if you could calibrate your model so if you could write down the equations for the physical system you got the ball it's slowing down and their drop standing you write down these equations that calibrate them to a specific table then in that initial bit of time you could collect enough information to improve your predictions about where the board land you'd never get exactly you didn't need to you just need to get some idea of which region the table is going to land in enough to get an edge over the casino it's all well and good of course doing that in a classroom and working for locations or the equations but in a casino you need to do it in real time you need to do that on the casino floor as the ball is spinning so what these teams actually did was come up with hidden computers to do these calculations in person now wearable technologies of course all around us these days but the first Wellwood computer was designed for this purpose as it happens and because it was a new technology there were of course some drawbacks with this they'd often give themselves electric shocks for example and as well as this as amazing things are very sensitive to initial conditions so if the weather changed they would need to recalibrate to the toilet table in one occasion they were actually losing federate money and couldn't quite work out what until every lies as an overweight tourist further down leaning on the table and screwing up all of their predictions so really these kind of methods were somewhat imperfect in theory they worked very well but these kind of stories have been a bit sporadic but it wasn't just roulette during this period the gamblers started targeting they all started targeting other games and actually one of the most successful gamblers in the world is a man by the name of Earl Benton and when he was a student in the 70s he came across this sign in an Atlantic City casino that's him this sign meant one thing card counting clearly works an old idea of card counting is if you have games like blackjack you're you're trying to get to a certain total pain the dealer and you know impact out you trying to get knit 21 but not go over so you got draw cards and try and get near this total and the face of it this is a random game the draw is completely random what will come up of course it's not for a deck of cards because if certain cards have already come out they can't reappear until you shuffle the deck so if you can collect information on what's already appeared this can potentially give you an edge over the casino it can give you an advantage against them now again casinos started realizing players were doing that they were tracking what within the deck so they started using more decks of cards rather than one they would use a whole pot and it's made it much harder to card come because if there's multiple of the same card in the deck it's much more difficult to keep track of what's come out what hasn't the casinos vertically handing the gamblers a very significant advantage because at the time seniors typically use what's known as a dovetail shuffle so this is probably familiar to you split the deck into you riffle the cards together now of tail shuffle if you do it once preserves an enormous amount of information about the cards so just to give you example let's say we have a sequence of cards in order from Ace to King if we do a dovetail shuffle we split them I've colored them just make life a bit easier and then we riffle them together now they might not fall exactly into woven you can see here in two different colors you've got to quite clear what's known as rising sequences of numbers so cars have been shuffled but actually if you know where they started at each point as you go from left to right you know there's only one of two cards that could be appearing and actually there's no other magic tricks that rely on this fact so if you get deck of cards and move one and then riffle shuffle you can spot with the move card because it won't fit into one of these rising sequences as you mathematicians have shown that for this kind of shuffle you need to shuffle the deck at least half dozen or so times to get something that's as good as random and in casinos in that period people were actually only shuffling them once so really if you can track what's happened you've got huge amount of information about what's going on and in many cases they would actually sneak in pieces in again another application of computers and casinos to track the cards that have come previously in whereas before card counters would measure what's come and then get have some approximation of what's left now they would actually at each point in time know that it's only one of two cards that could have pierced this is a true if ik advantage that they had but this poses a challenge because how do you capitalize on that at each point in time let's say there's a card that's advantageous and less beneficial how do you make that decision about how much to risk in that situation and what I want to do is just talk to a simple example let's suppose we have a coin toss and I'm going to offer you a biased bet I'm going to offer you two-to-one odds on tails so in other words you name an amount of money if it comes up heads you pay me that amount of money if it comes up tails then I will pay you double the amount you names so clearly that's a pretty stupid bet on my part I'm giving you an advantage but how much would you be willing to whit risk after all it is a coin toss and you would still have a chance of losing money did I just get a quick show of hands who here would be willing to risk 1 pound on that bet sure pants ok so I think most of you I'll keep your hand up if you'll be willing to risk 10 pounds okay how about a hundred pounds okay and that's 500 once okay so there's a few people left I'm not sure if they're paying with monopoly money but okay so if you put your hands down that wasn't legally binding then why but I want to give give you a chance to kind of get a feeling a measuring risk how much you willing to listen a situation and I know if you can see by actually the hands going to went down a lot between ten and a hundred pounds but this is it's quite important question for gamblers naturally in the 50s a physicist called John Kelly started thinking about this idea of bias bet suppose you have inside information and you have some edge over a bookmaker or casino how do you exploit that in this situation for you um although I gave all of you the exact same bet mathematically is the same offer your perception the value of that was very different some of you valued at a pound some ten some at 500 what's the optimal thing to do that exactly there's this concept known as utility and economics it's the value of something changes depending on how much money is in your wallet for example and how much you're willing to lose what Kelly did is he looked at these these kind of to contrasting aims you have if you want to give a good long term return so what you're first trying to make money because you've got a bias bet we also trying to avoid going bankrupt essentially you're still tossing a coin that set chance you're going to lose you know if you I don't think anyone here would have bet their house on this maybe you would of you might have an angry family but in this case you want to somehow exploit it but also limit your losses what Kelly did was can't come up with this formula so apologize to my handwriting basically you've got the odds which in this case is two you got the probability you win this P win – the province you'll lose and this is the optimal fraction of your money to bet for a given edge over somebody in a wager situation so the bet I just showed you the odds were – the probability you win is 1/2 because coin toss probability dude is also hot so if we stick these numbers in you get the following kind of equation a little bit of arithmetic you can kind of end up with 1/4 so in a situation if you want to maximize your long term growth of money it's optimal to risk about a quarter of your income just have a think back to kind of when you're raising hands whether that was a quart of you know where are you taking advantage or not now some of you might think ok that's what welling good you showed me a formula let's test it out now I could of course adopt the Carl Pearson approach and spend the next kind of half an hour so tossing coins to convince you that's a bit boring so what I thought I'd do instead is show you some simulations if we adopted different strategies what kind of outcomes would get so here along the vertical is your bankroll I'm going to assume that you start with a hundred pounds and along the bottom is the coin flips so we have played this bet again again again and see what you'd end up with over time now you might have felt a quarter my money you know that's a that's not taking risk so I want to go big you might say well I want about 80% of my money and in this case if we just do one random simulation and what might happen is you'll get a couple of big wins at the start you know you're approaching a thousand pounds blues load of money win a load of money it's exciting and then lose all your money and go bankrupt that's exciting if you adopt this optimal Pelley strategy and bet 25% what will happen is it will take longer you'll grow a bit slower over time but you won't go bankrupt and actually in the long term you will get something that takes off you might say a that's still a bit too much for me I'm going to bet 10% of my income on each one of these wages and in this case if you do it randomly it will take a long time to grow so you won't go bankrupt but it will take much more time to bet your money who notice this kind of increase is quite steeply at the end and that's because you're reinvesting your money it's this kind of compound interest effect over time again this is just one simulation it's a coin toss is a bit of randomness so what we could do is simulate it take ten times instead of the sort of one instance here do each one of these ten times over and in the case where you bet 80% you're going to end up with something which nine of these you go bankrupt one of them you do make a bit of money but in most these cases you'll run out of your income pretty quickly if you bet 25% this optimal amount then again it grows a bit slower but you don't go bankrupt at any point and you will eventually grow your income and then again this 10% it's just a much slower growth so just takes much much more time to build this up over over the series of bets and this is the strategy that people use playing blackjack playing a lot these games to manage their bankroll and actually the concept of utility and money management obviously important in finance but it underpins the entire insurance industry because whether we insure something or not depends on how we value it you know whether we're willing to risk the fact we could lose it and cost ourselves a lot of money or whether we take those small premiums that would depend on the value of the item the implementing the strategy of course for card counters conceal the apartment as one card camera I talk to unsaid learners card count is easy learning to get away with it is very difficult and many of these people who are successful people like Bill benta soon became pretty well known in the world casinos and found themselves banned from all the way around the world so they turned their attention to a bigger game a much larger place to wager now this is happy valley racecourse in Hong Kong if you ever been Wednesday night this is kind of where all the action is on a typical race day about 150 million dollars are wagered gambling is an enormous part of what's going on here all the appeals for this for gamblers is it's a fairly small um well first is it they're pretty convincing it's an honest operation and it's a small pool of horses about a thousand horses of run again again again so you can generate lots of data to look at and try and interpret which horse might have a good chance but to do that of course you need some way of converting data into a measure of performance which horses the best which horse is going to win and to use this teams turn to an idea that was first candid up by it by this man this is Francis Galton a Victorian scientist and cousin actually of Charles Darwin and as you can see they they shared some passions particularly for cravats and shiet sideburns but there were some differences Darwin actually was meticulous in shaping his research so even theory of evolution you can see many of his finger prints over this now I'm go to in kind of like think of himself more as an explorer he would sort of dabble in anthropology and psychology and biology and economics and then so start it off a bit and then leave it and wander off to something else and one of the things he was interested in was inheritance and he asked a year on some occasions would send his friend seeds and getting to grow them for him it's kind of an early crowdsourcing approach and getting to report back and one things you've noticed is that if you grew season and had the subsequent generation if those were for instance taller you wouldn't expect the next generation to be taller and taller and taller that over time you get a feature which he referred to as regression to mediocrity that over time these kind of features were somehow converged and the influence of the older lineages might kind of smooth over variation he wanted kind of understand this and slightly more rigorous way and it's actually a horse trainer who presented him with a figure which allowed him to frame this kind of idea and it was the following it was a diagram it was a square which represented the characteristics of a horse and his trainer had proposed that about half of the characteristics were explained by the mother and the father so we have a couple of squares for those and then of the remaining characteristics maybe a quarter is explained by the four grandparents and then another chunk is explained by the great-grandparents and so on and this idea was one of the founders of what's known as regression theory in statistics this idea that we can take a number of factors and work out how it influences the characteristics of a certain object or system and we could have a similar approach in horse racing we could say well let's suppose this box is the performance of the horse and we have lots of different bits of parse data and we could say well maybe each one of these bits of data explains some amount of the horses performance of course this is a bit simplistic really isn't it because just like with the characteristics of inheritance where for instance some of the variation explained by the parents that also could be shared with the gram the catchiest horse these features are going to overlap some of these will explain multiple aspects so these cuttings are going to be a bit more jumbled up and what's more we might not be able to explain all of the horses performance there might be some chunk which we still can't explain really the aim from a statistical point of view is to try and minimize this unknown quantity it was actually in the 80s but mentor visiting librarian Nevada came across a paper by two researchers called Roose Bolton and Amanda Chapman they work in marketing they still do actually and they dissent the outline this method for horse races this approach of converting data into some kind of measure of performance that you could use to make predictions and as bill said it was the idea that sowed a multi-billion pound industry and incredibly important this was actually food Bolton it was the only paper she wrote about horse racing is during her PhD and it was really kind of a side project but this had a huge impact on this industry and I'm doing the analysis there's early syndicates in hongkong certain things would come out as more important for example in one of their early research the number of races a horse at one will tell you a lot about how it's going to do it's tempting to come up with a story for that we say well if it's run more races then it's going to be more experienced and then that's going to give it a better performance in the next race but they actually avoid doing that because really they know it's a jumble that all of these things are kind of going to overlap and explain one thing and it's not clear that just because something's important it has a direct explanation there's quite a common problem in statistics it's known as this idea that a correlation doesn't always mean causation just even example here we have along the bottom is the wine spend per year the Cambridge colleges on the vertical is the exam results Suzy as you can see this a pretty strong correlation which in colleges this memo online have better result and this is new only thing that's happened actually it turns out the countries that have a higher per capita spend on chocolate typically win more Nobel Prizes as lovely as it would be the eating chocolate would make your Nobel Prize winner and thinking why we make you better exams there's clearly something else going on there some underlying feature which explains all of these things and really these syndicates therefore don't try and untangle it and that's one of the remarkable things is they have no desire to be pundits and experts on this kind of field for them the question is what horse is going to win not why is that horse going to win so it's almost this going back to idea of ignorance they're embracing their ignorance and saying yeah I don't really mind I can't explain exactly how it's going I just want a method that it's going to give me good predictions now starting off by measuring performance is one good thing but actually when you have multiple horses racing you can get some slight unexpected results occurring so just an example of a simple one let's suppose we have two horses we have one which half the time does well half the time does badly on the day you don't know which it's going to be and you have the second horse which is a bastion of reliability every single race exactly the same performance now on average over lots and lots of races they've got the same kind of performance because the top one on average that will cancel out and in a race it will be a essentially a 50/50 because it completely depends in a race whether the top world's number one is having a good day or a bad day so these two horses race against each other it's basically a coin toss is a 50/50 chance because the top was having a good day he's going to win who's having a bad day he's going to lose that's kind of intuitive but if you had a third horse into the mix something a bit strange happens so let's suppose we have a third horse here which some days performs slightly better than the middle horse Sunday's perform slightly worse so again on average all these horses have the same performance now by the same kind of logic the top horse here again has a 50% chance of winning because half the time he'll come out four and half the time he'll come out last so he still has a 50% chance of what of the two horses that remain if the top horse doesn't win we can kind of apply the same logic of these two horses on the bottom if the horse number three has a good day he's going to come out on top and if he has a bad day he's going to lose so if the top horse doesn't win you split the probabilities between the two horses for main links you can't decide now just we'll take a look at what's going on here all these horses on average have identical performance but it's the variability that's different and actually the top horse because it's most variable in this kind of race has a larger chance of winning you can actually apply the same kind of logic to other situations so say we have an election which with the first-past-the-post system so the person who gets most votes wins if you have three people who on average you would expect to get the same amount of those is actually the most polarizing candidate the kind of all-or-nothing one which has the best strategy because they've got the largest chance of winning in this situation if you want to push the example a bit further you can so look at job interviews or maybe even dating if you've got lots of different suitors in this situation it makes most sense to adopt this all-or-nothing kind of marmite strategy if the objective is to come out first against multiple people this isn't a problem if there's only two in the race but since you have multiple competitors you get this kind of weird dynamic coming out and really the mathematics of games and these kind of features of interest to mathematicians for a long time actually the origins are gamed through the origins of mathematics of games originated with poker in the 1920s a researcher called john von neumann brilliant mathematician he was the youngest professor in the history of the university of berlin wasn't so good at poker though on the face of it pokers a perfect game for mathematician right it's the probability you get a certain hand the probability your opponent gets a different one but von neumann realized there's more to it than that he said real life consists of bluffing of little tactics of deception of asking myself what does the other man suppose I'm going to do and he wanted to study that kind of feedback between what you think what they think and they think you think he looks of a simplified forms of poker one situation he looks at with two players they each get dealt a single card and then they put some money in the pot at the start and the first player has the toy so they can either just stick with their that in which case it just turn over their cards and compare them or they conveys the stakes and then it's up to the second player to decide whether they meet that bet or not so two players one card money in the middle what one women found is that in these kind of games you've got almost a tug-of-war because each player is trying to maximize their gain while simultaneously trying to minimize their opponents game if you think game like poker anything your opponent wins comes out of your pocket so you're trying to maximize what you get while at the same time trying to minimize what they get which means that there's this kind of equilibrium point at a point at which the two sort of conflicting forces balance and this situation analyzing for the game he found that this situation in which no player would benefit by changing their strategy this disbalance point for the first player the strategy was as follows that if they got very high card than they should raise the stakes intuitively this makes sense if you have a good card you know you might as well bet on it if they had a middling card it didn't make sense for them to raise the stakes didn't have a great chance of winning but they still had some chance so in other words they should just stick with our existing bet when Vannoy Minh looked at what happened when you got the lowest kind of cards he found that it doesn't make sense to stick with your backs if you turn over the cards you probably gonna lose instead you should up the stakes so in other words you should Bluff and actually up this point gamblers had often in poker players often bluffed in games but it was always seen as a quirk of human psychology a kind of innate trickery that humans came up with but he was von Lohmann showing that it was a mathematical necessity in other words he proved that bluffing is a necessary part of life and yeah this this idea it's got fundamentals game theory that you can have these strategies put together in this very simple version of poker though there's almost a list of fixed rules we can follow so in other words if you get high or low card you raise the stakes if you get a middling card you stick with what you've got and in any any game where you've gotten information in front of you so other games for instance things like noughts and crosses checkers chess all of these games in theory have a fixed set of rules it's known as pure strategy so you follow these exact rules and you'll get the optimal result so if someone noughts and crosses I think most people can kind of work it out when they're younger that they they realize there's a set of moves and if they always do that they always get the results that's best possible of course not all games are like this a good example is what paper scissors so it might be admirably consistent of you to always pick the same one but if your opponent sports what you're doing they can take advantage of that so it's not the kind of optimal strategy if you're trying to make your opponent's decisions as difficult as possible and these kind of games that's what you're trying to do you're trying to make your opponent indifferent to changing so you've got that tug-of-war going on so if they can gain more by adopting a different strategy you haven't got the optimal approach and in what paper scissors if you want to make your opponent's choices as difficult as possible what you can just simply do is pick randomly if you pick completely random options amongst those then in the long run your opponent won't be able to make any money off you so this is kind of the optimal thing to do then what Paper Scissors there's three options it's not too hard to work out that picking randomly will make your decisions difficult but games like poker far more complex you have a whole array of choices that you can make through the game so it's not something you can actually write down with pen and paper unfortunately we can turn to a technique that one of Tom Palomas colleagues devised and this was a petition called Stanislaw ulam and unlike many mathematicians he wasn't a big fan of working through loads of equations on one occasion he was working a blackboard trying to solve a quadratic got the end and was just so frustrated Ninoy he went home for the day so it really kind of wasn't his thing to kind of crunch through all this algebra he was once playing cancam field it's a version of solitaire and he wondered what the probability would be if he just laid out the cards what's the probability you'd have a situation where he could win that game if the cards would fall in a favorable way started looking calculations and realize it was just a lot of effort so instead he thought well what if I just lay out the cards a few times to see what happens in other words what if I just simulate this process a few times and get some sense of how likely is and the time lamin von Neumann working on the US nuclear program at Los Alamos working on Neutron collisions and thought the project was the hydrogen bomb and again these were random processes where you couldn't neatly write down the formulas and solve them and they realized its method would be incredibly powerful for that being a government program they needed a code name for it so they called it the Monte Carlo method ulam had a heavy gambling uncle at the time and Monte Carlo method has become a fundamental part of science I mean in my line of work where we try to look at disease outbreaks you have some like a bowl of Zika that's incredibly complex set of interactions it's not something you can write down with pen and paper neatly and so we use these simulation based approaches simulating these random processes to understand these systems it also appears now as a sports betting when you're trying to to understand how these very kind of complex team interactions work and it also applies to poker teams have used this kind of approach for a games of poker where you can't neatly solve the equations you can use a simulation based approach to get the computers to learn naughty alan turing in one of the fathers of computing and when he's first thinking about this idea of machine learning said that actually if you're trying to build intelligent machine it doesn't make sense to build the adult mind you don't to try and build the finished product with all the knowledge moves it makes multiple sense to build the child's mind and let it learn let it work out how to play these kinds of games and this is what these poker teams do they create these algorithms that can learn and actually the way in which they learn is perhaps a bit surprising because what they do is they get these algorithms over time to employ what's known as regrets minimization so as they play these games billions of times against each other at each point when they've made a decision they look back and say could I improve that if I'd done something differently so each point they kind of have a artificial measure of regrets for each decision they make and actually there's a lot of evidence from some neurological side neuroscience studies that that ability to have regret it's quite quite important in learning games of chance it's been studies of people who have damaged a bit of the brain that's responsible for regret disabilities now look backward and ask how would I feel if I've done something differently and if people often are perfectly capable of playing logic games if you have to sort cards absolute you find out that if there's le any element of risk to the game and they have to learn how to play the optimal strategy that's something they really struggle with and actually a lot of economic theories developed not around looking back but around what's known as expectation maximization so in other words you look forward and you say if I did this could I make money if I did this could I make more but really from these kind of artificial intelligence approaches it seems that it's much more powerful to look back how to employ that power of regret as you go to come look back on your decisions as you take these risks and in fact these teams have employed these algorithms and got these computer BOTS to page there are so many times that last year they announced that poker is solved well for to be specific for two-player poker where the the states have a limit these BOTS a page so many times that they've come up the strategy which will not be expected to lose money in the long run so even if you're playing a perfect opponent this bot would not lose money over the course of a very long game um interestingly actually a lot of the players who came up with this system a lot of the computer scientists aren't very good at poker themselves by their own admission they're not poker players so it'll kind of a market illustration of the power of these algorithms you have people who aren't particularly good at poker creating poker bots that can beat any human arguably but they're yeah this is a remarkable achievement but there is of course a downside of this and that you're assuming that your opponent is perfect if you're kind of looking for this optimal strategy that's inherently defensive because you assume in your opponent's perfect and you're almost giving them too much credit so if you've got flawed opponent and you're coming up with a strategy that zooms they're perfect you're kind of potentially not exploiting them as much as you could I just think giving example of these kind of flaws that could occur let's get back to what Paper Scissors what like you ought to do you just turn to the person next to you and play a couple of games of what Paper Scissors with them please okay thank you ladies and gentlemen okay I can see there's a couple of people back to UM play a best-of-seven or something but um okay what I'd like to do just come quick show of hands of who opened with rock there okay a fair few who open with scissors quite an who open with paper okay a not so many actually babe um so typically in these kind of big competitions we play lots times um it's novices that opens vaak often men sorry scissors tends to be the kind of most popular people who play a lot of these games um the papers not always chosen to come in also think about what happened between the first game in the second game you play because in one sort of fairly large study what paper scissors what happened was people who win the first round typically stick with the same move for the second go so this cut old um the military adage isn't it of generals always fought la always fight last war especially if they won it so as idea that if you won you just stick with what save people who lost however and will often switch to the move that would have beaten the one they lost it so if they lost to rock they'll often swap to paper on the next go so it always happen but in these kind of large competitions these kind of patterns emerge although the optimal thing to doing what paper says is to pave completely randomly people don't they fall into these predictable patterns and there was actually a story a few years ago in Japan an electronics firm wanted to auction off their art collection and they approached Christie's and Sotheby's to hold the auction they obviously both keen to do and so the head of the electronics firm decided the fairest way to settle it would be with a game of rock-paper-scissors now Sotheby's thought that's perfectly random that's nice that's fine Christie's however he the the CEO in Japan had a young daughter 71 who played relentlessly in the playground so he got his daughter to teach him a bit of rock-paper-scissors strategy and they walked in sure enough to the boardroom Sotheby's treating Iran and getting Christie's with a strategy Christie's walked out the winner so in this kind of case exploiting those patterns and those kind of predictability and knowledge of what's happened before it can be extremely valuable but there are some challenges to that and particularly if you're playing kind of computers one of the challenges from a human point of view is the limitation of our memory so just come in at this point what lights you now is to just all of you try and memorize that number for me so I'll give you a couple of moments can I have a quick look at it okay but um who fancies having a go at trying to a slice it any volunteers yes sir very very close I didn't want to have another go what would support your name sorry Gavin so Gavin got very close anyone to try and build on that yes okay so what your name Steve Steve run reports to Steve ladies and gentlemen now Steve is something quite clever there then if you spotted it um I spent we did so I asked you to memorize ten digits and that was actually a bit devious to me because in a lot of psychological studies people presented with numbers can typically memorize about seven and recite them um so five digits in what oh sorry yeah okay I do have a PhD in math I'll show you okay so actually I made it even harder I was cooler than I thought I do I do apologize um and so it typically people can remember like a local telephone number they can member to UM they struggle with but what actually Steve did when he was slightly the numbers he didn't recite there's kind of individual he said like six ten to sixty in 1091 so that's what he did he bunched the numbers together he wasn't reciting temperature information he was chunking it into a smaller amount which kind of put it below that threshold that you can memorize and actually other countries so in France Vince if you go their telephone numbers tend to be paired together which actually makes it easier to remember the numbers because it's much easier for you to remember these curved chunks of numbers rather than just a single sequence I can't guarantee that that all of you will remember this number when you get home tonight and that's actually if you split it apart and add in some punctuation and then flip it round that's just the time and date of this talk so all of you now will know that number and be able to recite it and the reason is you've gone from ten bits of seemingly arbitrary information down to one that clearly has some meaning to you and this ability to chunk is something that card counters employ because clearly memorizing a whole deck of cards is incredibly difficult so what they do is they use what's known as bucketing they will group into say low cards medium cards high cards and then more than having to memorize a whole deck that only have these three buckets to remember and what's more it's kind of a memoryless opposites they don't have to remember everything that you can just keep the tallies of these three values of course there are some people out there that can memorize the first numbers of cards you know the top memory champions can memorize about a thousand cards in an hour thousand paper cards are now markable and the way they do that is they actually attached characters to the cart this will make them people an object and they attach a story to that it's similarly like while you will all remember this because you're not remembering a number you're remembering an event you remember a single thing which is much more memorable and that's you really kind of have humans can get around this idea of the limitation of memory but there are some disadvantages to learning about your opponent and remembering things and trying to take advantage of them and that's if the if your opponent is incredibly they could teach you the wrong image of themselves so it's what's known as the get caught and Exploited problem if you're playing poker for instance your opponent could pretend to be very passive and pretend to be very timid and then once you kind of learn that notion of how they play they could actually switch their behavior and exploit the fact that you've learnt the incorrect perception of them it's not just poker that's happened a couple of months ago you may have seen it's a Microsoft launched a bot for Twitter to learn from – you can see where this is going to try and learn language no ideas have conversations and improve its ability to learn tip twitter users and for chily decided to teach it some unfortunate tricks what actually happens in 24 hours it had to be taken down because it was coming out with so many horrendous opinions I think that's an example of you have quite intelligent algorithm but if it's being fed the wrong image of what it should be doing it can actually very off track very quickly and at this point if you have talked about poker BOTS would pay billions of gains to find their strategy I've talked about these these language BOTS in many situations these bots aren't very complicated in finance for example programs are designed to be fast if you're trading if you wanna get trade off use do that quickly so having that huge amount of complexity and nuance and Latin ality in your algorithm isn't going to do the job you know you really want to strip it down as simple as possible in many cases these high-speed algorithms you might just have a few lines of code and there's one economics researcher might also you put it where do ten lines of code you're not even insect level intelligence you've got no rationality or no nuance in there you just trying to execute the trades as quickly as possible in some situations this means that you can run into trouble there's a case um recently in Norway where two traders had noticed that a US stock broker had an algorithm that was feeding trades at the market and the algorithm would always react to a trade in the same way so in other words if you traded with it it would change its price by the same amount no matter how big that trade was so what these um even though I did was teach the algorithm what to do so it made lots of little trades so it would move its price up and it'd make a big trade and profit from the difference now this ended up in court these two trade were charged with market manipulation and handed suspended sentences but then there's kind of a Robin Hood reputation in the media for them annoying it went to appeal and their appeal all made the point of if they had been trading against a stupid human who was doing this that wouldn't be a problem the issue is that they were trading it's stupid algorithm presumably created by a human that hadn't been thinking what they were doing and how should this be different how did the notion of skill and responsibility be different because there's a kind of one step away from and actually this argument held in in court and in this situation they were actually you know this distance was revoked and it is in the first since the very simple algorithms run into trouble um a similar points actually a u.s.

Stockbroker was introducing a new algorithm to feed orders in four markets you have a lot of orders from clients coming to stockbroker and it would want to feed them in they had eight servers doing it what they had is a counter actually to keep track because obviously if you're got lots of orders coming in and you also send them out for market you want to keep track of how many you've completed you don't want to kind of accidentally make too many and they had one of these counsel at each server and then they updated their software but by all accounts they didn't add the counter to the eighth server so seven servers that knew what they were doing the eighth one that's kind of doing its own thing and when this went live what happened was the seven were behaving as they should the eighth just peppered the market with high speed trades and actually by the time they they worked out what's happening and shut it down in 45 minutes it lost about 450 million dollars so that's that's a hundred seventy thousand dollars a second for this runaway algorithm because it was acting so fast and so much beyond what consumers could control and you might pull that bad luck you might call that so error in skill and I think those cases around these kind of games and chance events a developing actually in the u.s.

In recent years has been a big crackdown on poker particularly online and as well in 2012 there was a crackdown on New York poker rooms and gentlemen who's running a poker room was was taken to to court and charged with operating a gambling operation now many games in federal law are defined as gambling but poker isn't one of them so actually that whether it was gambling or not was kind of up for debate and if federal law gambling is defined as anything that is predominantly due to chance so any game that's predominant disolve chance is defined as gambling so what happened is this entire legal case rested on its poker game of chance or game of skill and they got economists coming in mathematicians and they made the point that on a single game of poker of course as an element of luck because you've got this deal but then equally in baseball it's someone pitching a single bull there's going to be an element of chance involved but over the course of a poker game typically the more skillful players won and this is the first time actually that a US Court had ruled on whether poker was game of chance or game of skill and they've ruled that it was a game of skill there's a footnote to story the following year when the it went to the state appeals court now in New York state law gambling is defined as anything that has a material element of chance so you think about this is a much narrower definition of gambling it's not predominantly chance as anything with a material element which clearly poker does have and under this condition it's defined as gambling and it's debate is ongoing if you know kind of fantasy sports in the US and lot of these systems where do we have something that's luck do we have something skill where do we we actually define these things as gambling I think there's often a temptation in fact with the situation to put things in boxes you know we like to say the box with lot and there's a box of skill I think typically if we're good at something it goes in the Box on the right but bad is something it goes in the box on the left and that's really kind of tempting but I don't think it's a realistic notion necessarily I think particularly you know through the history of how people have tackled games like roulette and with lotteries is much more of a spectrum actually games that we might think are the archetype of luck things like roulette actually if you have a skillful approach you can tame that chance and you can convert it into some element of a game of skill and even games that we might think are incredibly almost solely the work skill games like chess it can have surprising results a chance in the 90s famously IBM's deep blue chest computer play Garry Kasparov and during the match in more the early games there was a situation where deep blue made a move that was so unexpected and almost kind of so subtle that it through cast off of it and it all accounts convinced him that he was playing something there just simply beyond what he was yeah ever seen before just something completely on this capability it turned out actually that what happened there is deep blue had run into a situation where it couldn't identify the best move and in that situation it'd been programmed to pick randomly so this this set of games that is one of the landmarks in artificial intelligence over humans in a game that is thought to be purely skill was actually really kind of shaped by this chance event and I think these kind of illustrations show why gambling and why these kind of games of chance are so important because really whatever your views are of casinos and bookmakers gambling is an inherent part of life betting is an inherent part of what we do whether it's in health in kind of prediction on this side whether it's in business within finance we have to make decisions with hidden information we have to deal with uncertainty we have to balance the risks against the rewards I think that's why historically so many research has been in us and gambling and continue to do so because really if you want to understand luck and decision making and risk then arguably there's no way a better to start than with a bet what your view are we're investing in the stock market might fall between luck and skill should I pay somebody a 2% fee for their skill in investing my money or should I just rely on buying the market