📜 ⬆️ ⬇️

Rates on bookmaker ratios on the example of Formula 1

Miicky

What are we talking about



I am a true Formula 1 fan. I've been following races since the age of eight, in the working calendar all the dates of the Grand Prix are listed, and through RSS I read several thematic sites. At one of them annually held a competition of forecasts. The rules are simple - before each Grand Prix you need to predict the top ten riders at the finish. Following the results, two tables are compared - ten pilots indicated by you in the forecast and ten best pilots at the end of the race. Predicting the top ten is difficult because of unforeseen circumstances in the form of car fires, accidents or breakdowns. Because I answered one simple question - who earns the most bets? Of course bookmakers. So what are the chances of winning the competition, if you put on forecasts, for example, the British office of William Hill ?

The rules of the contest are simple. Pilots who finish outside the top ten are not counted. If the pilot finished at the place you indicated in the forecast, you get 25 points, if you make a mistake on one position - 18 points, on two - 15 points, on three - 12 points, on four - 10 points, on five - 8 points , on six - 6 points, on seven - 4 points, on eight - 2 points and on nine - 1 point. (Riders get the same points for finishing the race). Points for each position are summarized. In determining the winner at the end of the season, the results of the five best forecasts are taken into account.

Getting Started


First, I found the forecast of the bookmakers before the race, as well as the results of the races and put them in one table.

I had no desire to read the results for all 20 Grand Prix, because it was decided to write a small script. But I programmed the last time at school, and using Google Developers documentation and their platform, I managed to sketch a working script for quite a long period of time, recalling the extraterrestrial feeling of a working script after thirty minutes of searching for an error.
')
* Sample Australian Grand Prix 2012
NoRaceForecastPoints
oneButtonVettel12
2VettelHamilton18
3HamiltonWebber18
fourWebberButton18
fiveAlonsoAlonso25
6KobayashiRosberg0
7RaikkonenRaikkonen25
eightPerezSchumacher0
9RiccardoGrosjean0
tendi RestaWeight0


Example code for scoring, sharpened by this table

function points() { var sheet = SpreadsheetApp.getActiveSheet(); //    var race, forecast = new Array(); //    var points_race = new Array(25,18,15,12,10,8,6,4,2,1); //  for (var k=3; k<=215; k=k+11){ //   race = sheet.getRange(k, 2, 10, 1).getValues(); //   forecast = sheet.getRange(k, 3, 10, 1).getValues(); //  for (var i=0; i<=9; i++){ sheet.getRange(k+i,4).setValue(0); //    "0" for (var j=0; j<=9 ; j++) if (race[i].toString() == forecast[j].toString()){ //  sheet.getRange(k+i,4).setValue(points_race[Math.abs(ji)]); //  break; //    } } } } 


After calculating the sum of points for each stage, using the LARGE function, I chose the five best results.

Top five
The Grand PrixTotal points
India156
USA155
Canada118
Singapore117
Australia116
Amount662



First conclusion


Despite a good overall result in all races (2064 points), my top five (662 points) did not manage to compete with the top three winners (789-767 points), but the result was better than my own, built on “flair”.

To not give up


I did not stop at that and made a total of seven different forecast functions.
  1. Above described - the forecast was calculated by the rates of bookmakers for a separate stage;
  2. At bookmaker rates for winning the championship, before the start of the season;
  3. The bets of my pet cat "MatzYka", which walked on the keyboard - a random dozen riders, one for all stages;
  4. Random dozen riders for each stage is different;
  5. The results of the first practice;
  6. The results of the second practice;
  7. The results of the third practice.


All results in one table
PaymentScore 5 best results
Bookmakers stages662
Champion Bookmakers640
Random-one (Matyk)569
Random-all542
First practice596
Second practice712
Third practice622


findings


In the final part of the article there should be a conclusion, and I have a problem with this :) Before starting work, I thought that the forecast would be, if not the best, then at least close to it. But another was confirmed - to show a good result at the expense of only a simple theory of probability does not work, you need to modify the existing algorithm with other variables. On the other hand, I amused my own, who forgot what programming is, the brain, decided an interesting task for me, and maybe for you, a task, and got a little bit of experience.

Post Scriptum


On github, the code was not flooded, since it is sharpened by a table.
The table and the script are available for viewing, to work with them, make a copy of yourself in Google Disk, to start the counting - menu "Gadgets".
If the reader has any ideas about how else to calculate the forecast - write to me, I will be happy to hear them.

Source: https://habr.com/ru/post/178233/


All Articles