Building a random bettor

For the next season of Fußball-Bundesliga, we’ll use kicktipp for betting on the results, as we have in the previous seasons. This time, we want to introduce additional dummies, ‘Heimsieg’ (home victory) and ‘Zufall’ (randomness), as yardsticks of predictive performance (i. e., if your bets are worse, you should be ashamed).

Of course, for Heimsieg the question is, what exact result should it use (two suggestions are 1:0 and 2:1)? And how should Zufall produce its values? Enter statistics.

Of course, you could just roll dice, subtract one, and use that for the bets, but some results (e. g., 0:5) are rather unlikely to happen in real life. Therefore, the idea is to construct a random bettor which produces results with the same frequencies as historical results.

So I took the results of the last two seasons (Bundesliga 2006/07 and 2007/08) and counted the results (or rather, let the computer do it). A 1:0 is different from a 0:1, of course. There were a total of 612 matches (2 × 34 × 9). Sorted by frequency: 1:1 occured 71 times (11.6%), 1:0 59 times (9.6%), 2:1 57 times (9.3%), 2:0 47 times (7.7%), 0:0 43 times (7.0%), and 1:2, the first loss for the home team, 41 times (6.7%).

The question whether Heimsieg should bet 1:0 or 2:1 is still a matter of taste, as the difference (59 vs. 57 times) is small. For Zufall, the result statistics offer a spectrum which to use for random bets.

Next step would be to predict the results for the next season of Heimsieg and Zufall by running them against the old seasons (with the rule set from kicktipp).

Some comments on programming (after all, this blog is called irgendwasmitcomputern and thus should have a computer angle, at least sometimes):

For counting the occurrences of results, a simple data structure comes handy, the bag (more pompously called multi-set). Python offers dictionaries, which are nearly all you need for a bag (it is amazing what flexibility dictionaries/hashmaps have to offer; Python, JavaScript, Common Lisp are well equipped with them; I can’t understand why Scheme doesn’t establish them in the core language). So, let’s implement a bag in Python:

That’s about it. You see why I love Python’s dictionaries. You just gather all results in the bag; afterwards you have to choose elements randomly, but according to their relative weight (i. e., frequency). Again, this is rather simple:

About Daniel Tiggemann

Software-developer living in Cologne, Germany. Was once a physicist, specialized in computer simulations and parallel programming. Now more into JavaScript, web frontend development, and especially mobile computing.