16
$\begingroup$

I've been trying to code an algorithm to suggest bets in 1X2 (weighted) games.

Basically, each game has a set of matches (home vs away teams):

  • 1: home wins
  • X: draw
  • 2: away wins

BWin 1X2 Betting Game

For each match and symbol (1, X and 2), I will assign a percentage that represents the chances / likelihood of that symbol being the correct match outcome. Here is an array representing the structure:

$game = array
(
    'match #1' => array // stdev = 0.0471
    (
        '1' => 0.3,     // 30%     home wins
        'X' => 0.4,     // 40%     draw
        '2' => 0.3,     // 30%     away wins
    ),

    'match #2' => array // stdev = 0.4714
    (
        '1' => 0.0,     //   0%    home wins
        'X' => 0.0,     //   0%    draw
        '2' => 1.0,     // 100%    away wins
    ),

    'match #3' => array // stdev = 0.4027
    (
        '1' => 0.1,     //  10%    home wins
        'X' => 0.0,     //   0%    draw
        '2' => 0.9,     //  90%    away wins
    ),
);

I also calculate the standard deviation for each bet (commented in the above snippet); higher standard deviations represent a higher certainty, while the matches with the lowest standard deviations translate to a higher level of uncertainty, and, ideally, should be covered with a double or triple bet, if possible.

The following pseudo-algorithm should describe the overall workflow:

for each match, sorted by std. dev         // "uncertain" matches first
    if still can make triple bets
        mark top 3 symbols of match        // mark 3 (all) symbols
    else if still can make double bets
        mark top 2 symbols of match        // mark 2 (highest) symbols
    else if can only make single bets      // always does
        mark top symbol of match           // mark 1 (highest) symbol

So far so good, but I need to tell the algorithm how much I want to spend. Lets say a single bet costs 1 in whatever currency, the formula to calculate how much a multiple bet costs is:

2^double_bets * 3^triple_bets * cost_per_bet (= 1)

Obviously, the algorithm should try to allocate as much money available as possible into the bet suggestion (it wouldn't make much sense otherwise), and now is where this gets trickier...

Lets say I wanna pay a maximum of 4, listing all possible multiples in PHP (@ IDEOne):

$cost = 1; // cost per single bet
$result = array();
$max_cost = 4; // maximum amount to bet

foreach (range(0, 3) as $double)
{
	foreach (range(0, 3) as $triple)
	{
		if (($double + $triple) <= 3) // game only has 3 matches
		{
			$bets = pow(2, $double) * pow(3, $triple); // # of bets

            $result[$bets] = array
            (
                'cost'      => $bets * $cost, // total cost of this bet
                'double'    => $double,
				'triple'    => $triple,
            );

            if ($result[$bets]['cost'] > $max_cost)
			{
				unset($result[$bets]);
            }
        }
    }
}

ksort($result);

Yields the following output:

Array
(
    [1] => Array
        (
            [cost] => 1
            [double] => 0
            [triple] => 0
        )

    [2] => Array
        (
            [cost] => 2
            [double] => 1
            [triple] => 0
        )

    [3] => Array
        (
            [cost] => 3
            [double] => 0
            [triple] => 1
        )

    [4] => Array
        (
            [cost] => 4
            [double] => 2
            [triple] => 0
        )
)

The Problem

If I choose to play the maximum amount of money available (4) I would have to bet with two doubles, if I use the pseudo-algorithm I described above I would end up with the following bet suggestion:

  • match #1 => X1
  • match #2 => 2
  • match #3 => 12

Which seems sub-optimal when compared to a triple bet that costs 3 and covers more uncertainty:

  • match #1 => X12
  • match #2 => 2
  • match #3 => 2

The above example gains even more relevance if you consider that match #3 odds could be:

$game['match #3'] = array // stdev = 0.4714
(
    '1' => 0.0,           //   0%    home wins
    'X' => 0.0,           //   0%    draw
    '2' => 1.0,           // 100%    away wins
);

In this case I would be wasting a double for no good reason.

Basically, I can only choose the biggest (possibly stupid) bet and not the smartest, biggest bet.

I've been banging my head against the wall for some days now, hoping I get some kind of epiphany but so far I've only been able to come up with two half-[bad-]solutions:


1) Draw a "Line"

Basically I would say that matches with a stdev lower than a specific value would be triple, matches with a stdev a big higher would be double bets and the rest single bets.

The problem with this, of course, is finding out the appropriate specific boundaries - and even if I do find the perfect values for the "smartest" bet, I still don't know if I have enough money to play the suggested bet or if I could make a even bigger (also smart) bet...


2) Bruteforce

I came up with this idea while writing this question and I know it won't make perfect sense in the context I described but I think I could make it work using somewhat different metrics. Basically, I could make the program suggest bets (# of triple and double bets) for every possible amount of money I could play (from 1 to 4 in my example), applying the pseudo-algorithm I described above and calculating a global ranking value (something like % of symbols * match stdev - I know, it doesn't make sense).

The bet with the highest ranking (covering uncertainty) would be the suggested bet. The problem with this approach (besides the fact that it doesn't make any sense yet) is that the games my program is going to work with are not limited to 3 matches and the number of double and triple bet combinations for those matches would be substantially higher.


I feel like there is an elegant solution, but I just can't grasp it...

Any help cracking this problem is greatly appreciated, thanks.


There seems to be some confusion regarding my problem, I've already addressed this in this question and also in the comments but the misinterpretation still seems to prevail, at least to some.

I need to know how many triple, double and single bets I will play for a specific game (all matches). I already know what symbols I want to play by looking at each match individually.

$\endgroup$
16
  • 4
    $\begingroup$ The good folks over at math.stackexchange.com might be able to provide a better understanding to the problem you're describing, which might in turn suggest good ways to implement it :) $\endgroup$
    – Lethargy
    Commented Sep 27, 2011 at 0:53
  • 1
    $\begingroup$ @Lethargy: I once posted a question here about the Pascal Triangle and Prime Numbers that latter got migrated to math.SE. I got about 15 upvotes (both at SO and math.SE) very quickly but the question was closed in less than 30 minutes and it doesn't even exist anymore. I don't think they like these kind of "simple" questions very much. $\endgroup$
    – Alix Axel
    Commented Sep 27, 2011 at 1:00
  • 2
    $\begingroup$ If we optimize for Maximum number Wins this seems actually really easy. The average number of wins is simply the win chance of each single instance added together. Ie if we set a single bet on the maximum chance we'll win 0.4+1+0.9=2.3 games on average. So if adding 1 bet was always equally expensive, the solution would simply be to sort the win chances and take the first COST chances (this gives the "best" result for the example). If the cost is different when adding a second vs. third to something it gets more complicated (bruteforce recursive works though) and I think I'll sleep this over. $\endgroup$
    – Voo
    Commented Sep 27, 2011 at 3:19
  • 2
    $\begingroup$ As a mathematician who doesn't know php, I would find it much easier to attack this problem if it were in mathematical notation rather than code. $\endgroup$
    – Beta
    Commented Sep 27, 2011 at 3:46
  • 2
    $\begingroup$ Have you heard of the Kelly criterion? If not, there's some reading right there for you. $\endgroup$
    – AakashM
    Commented Sep 27, 2011 at 8:34

3 Answers 3

2
$\begingroup$

I think I came up with a workable bruteforce solution, it goes like this:


  • 1) calculate every possible combination of multiple bets I can make

For the example and amounts I provided in my question, this would be:

  • 3 single, 0 double, 0 triple = equivalent to 1 single bet
  • 2 single, 1 double, 0 triple = equivalent to 2 single bets
  • 2 single, 0 double, 1 triple = equivalent to 3 single bets
  • 1 single, 2 double, 0 triple = equivalent to 4 single bets

  • 2) calculate the standard deviation of the symbol odds for every match

             |    1    |    X    |    2    |  stdev  |
             |---------|---------|---------|---------|
    Match #1 |   0.3   |   0.4   |   0.3   |  0.047  |
             |---------|---------|---------|---------|
    Match #2 |   0.1   |   0.0   |   0.9   |  0.402  |
             |---------|---------|---------|---------|
    Match #3 |   0.0   |   0.0   |   1.0   |  0.471  |
    

  • 3) for every multiple bet combination (step 1) compute a ranking using the formula:

    ranking = (#n(x) [+ #n(y) [+ #n(z)]]) / stdev(#n)

Where #n is a specific match and #n(x|y|z) is the ordered odds of the symbols.

  • Matches are processed from low to high standard deviations.
  • Individual symbols in each match are processed from high to low odds.

Test for a 1 single, 2 double, 0 triple bet:

  • (#1(X) + #1(1)) / stdev(#1) = (0.4 + 0.3) / 0.047 = 14.89
  • (#2(2) + #2(1)) / stdev(#2) = (0.9 + 0.1) / 0.402 = 2.48
  • #3(2) / stdev(#3) = 1.0 / 0.471 = 2.12

This bet gives me global ranking of 14.89 + 2.48 + 2.12 = 19.49.


Test for a 2 single, 0 double, 1 triple bet:

  • (#1(X) + #1(1) + #1(2)) / stdev(#1) = (0.4 + 0.3 + 0.3) / 0.047 = 21.28
  • #2(2) / stdev(#2) = 0.9 / 0.402 = 2.24
  • #3(2) / stdev(#3) = 1.0 / 0.471 = 2.12

Which gives me a global ranking of 21.28 + 2.24 + 2.12 = 25.64. :-)


All the remaining bets will clearly be inferior so there is no point in testing them.

This method seems to work but I came up with it via trial and error and following my gut, I lack the mathematical understanding to judge whether it is correct or even if there is a better way...

Any pointers?

PS: Sorry for the bad formatting but the MD parser seems to be different from StackOverflow.

$\endgroup$
1
1
$\begingroup$

How about making a solution based on the Simplex Method. Since the premise for using the Simplex method isn't fulfilled we need to modify the method slightly. I call the modified version "Walk the line".

Method:

You are able to measure the uncertainty of each match. Do it! Calculate the uncertainty of each match with a single or double bet (for a triple bet there is no uncertainty). When adding a double or triple bet, always choose the one that reduces uncertainty the most.

  1. Start at maximum number of triple bets. Calculate total uncertainty.
  2. Remove one triple bet. Add one or two double bets, keeping under maximum cost. Calculate total uncertainty.
  3. Repeat step 2 until you have the maximum number of double bets.

Pick the bet with the lowest total uncertainty.

$\endgroup$
0
$\begingroup$

What i come from observing this sportsbets i came to thise conclusions.

Expected value
Lets say that you have 3 bets whit 1.29 5.5 and 10.3 (last bet in table) EV for betting is
EV = 1/(1/1.29+1/5.5+1/10.3) - 1 = -0.05132282687714185 if holds that probabilities one winning over another are distributed as
1/1.29 : 1/5.5 : 1/10.3, then you are loosing your money on long run since your EV is negative.
You can profit only if you can figure out what are probabilities of each outcome and find out irregularities.

Lets say that true probabilities are
0.7 : 0.2 : 0.1

That mean that rates should be 1.43 \ 5.0 \ 10.0

You can se that in this case best payoff is for betting draw since it gives you
EV(0) = 5.5/5 - 1 = 0.1
where for betting on loss is
EV(2) = 10.2/10 - 1 = 0.02
and betting for home win is even EV-
EV(1) = 1.29/1.43 - 1 = -0.10

$\endgroup$
1
  • $\begingroup$ I don't think you got my question. I already know in what symbols (and in what order in case of a multiple bet) to bet on each individual match. My problem is figuring out the ideal number of triple and double bets I should play by looking at all the matches (and their respective symbol chances) globally. $\endgroup$
    – Alix Axel
    Commented Sep 27, 2011 at 20:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.