Calculate the probability of each number in 3 columns

bilbon

Board Regular
Joined
Dec 19, 2011
Messages
83
Hi,

Is there anyone who can help me figure out the probability of each number on the different A-B-C so that it will be like the answer to the right.
Preferably with VBA.


Match%%%Probability % AProbability % BProbability % CNumber of RightProbability % AProbability % BProbability % C
1142561612514130,060,000,00
292629262120,600,000,00
3493021493021112,860,000,00
4502723502723108,260,010,00
5692011692011916,010,070,00
6483022483022821,930,390,04
7483022483022721,801,660,26
8492823492823615,875,241,29
956251956251958,4212,254,70
1028294343292843,2020,9512,39
1164221464221430,8425,5423,12
1267191467191420,1421,0228,93
1319305151301910,0110,4821,79
00,002,397,47
100%100%100%
This is the correct answer

<colgroup><col span="5"><col span="3"><col><col><col span="3"></colgroup><tbody>
</tbody>
 
Hi Kishan


I make an attempt to explain a little.
The game is to predict 1, X or 2 (winner, tie, away win) in 13 football matches,
I use it, among other things, to make a theoretical assessment of how the pros (those who set the odds) assess the weekly round.
Then there are many ways to limit the number of rows (totaling 1 594 323 rows) by setting filters to remove rows that you don't want to include in their system using these % numbers.
Just your own imagination that sets the limit.

/Bilbon
Bilbon, thank you for the replaying, I understood that the game is to predict 1, X or 2 (winner, tie, away win) in 13 football matches, also that the number of totalling rows will be 3x3x3x3x3x3x3x3x3x3x3x3x3 = 1.594.323 </SPAN></SPAN>

What I do not understand is following looking to the solution is provided by shg in to the post#9 </SPAN></SPAN>

Take an example for </SPAN></SPAN>
Match 1 according to % (1 has 61%) but according to Probability will you play 2?</SPAN></SPAN>
Match 2 according to % (1 has 92%) but according to Probability will you play 2?</SPAN></SPAN>
Match 3 according to % (1 has 49%) but according to Probability will you play 2?</SPAN></SPAN>
Match 4 according to % (1 has 50%) but according to Probability will you play 2?</SPAN></SPAN>

Match</SPAN>
1</SPAN>
2</SPAN>
3</SPAN>
k</SPAN>
Pr(k)</SPAN>
Pr(k)</SPAN>
Pr(k)</SPAN>
1</SPAN>
61%</SPAN>
25%</SPAN>
14%</SPAN>
0</SPAN>
0,000005</SPAN>
0,023946</SPAN>
0,074681</SPAN>
2</SPAN>
92%</SPAN>
6%</SPAN>
2%</SPAN>
1</SPAN>
0,000134</SPAN>
0,104848</SPAN>
0,217900</SPAN>
3</SPAN>
49%</SPAN>
30%</SPAN>
21%</SPAN>
2</SPAN>
0,001417</SPAN>
0,210233</SPAN>
0,289332</SPAN>
4</SPAN>
50%</SPAN>
27%</SPAN>
23%</SPAN>
3</SPAN>
0,008399</SPAN>
0,255402</SPAN>
0,231244</SPAN>

<TBODY>
</TBODY>


I could not understand how you reduce the odd using the Probability do have you any software which do reduce the lines?</SPAN></SPAN>

Please will be great full of anyone can understand and help about the Probability % </SPAN></SPAN>

Thank you </SPAN></SPAN>

Regards,</SPAN></SPAN>
Kishan</SPAN></SPAN>
 
Last edited:
Upvote 0

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Hi Kishan


Each % number is a character 1 X 2 and if I make a row with the 13 biggest % numbers I can see on the prediction table how many right it should be in that row. Then I do the same with the second largest and the same with the smallest. These 3 lines I put into a program and put the conditions on each line (6-9 right.1-5 right.1-4 right) which I colored. These 3 rows of the terms I set reduces the 1 594 323 lines to 300 872 rows.
This can be a basis when you are going to reduce but then you can continue with several conditions to get the radtal you want to play.


Match%%%ABC
114256161%25%14%
2926292%6%2%
349302149%30%21%
450272350%27%23%
569201169%20%11%
648302248%30%22%
748302248%30%22%
849282349%28%23%
956251956%25%19%
1028294343%29%28%
1164221464%22%14%
1267191467%19%14%
1319305151%30%19%
11X22X1
21X21X2
31X21X2
41X21X2
51X21X2
61X21X2
71X21X2
81X21X2
91X21X2
101X22X1
111X21X2
121X21X2
131X22X1
6-91-51-4
kPr(k)Pr(k)Pr(k)
00,00%2,39%7,47%
10,01%10,48%21,79%
20,14%21,02%28,93%
30,84%25,54%23,12%
43,20%20,95%12,39%
58,42%12,25%4,70%
615,87%5,24%1,29%
721,80%1,66%0,26%
821,93%0,39%0,04%
916,01%0,07%0,00%
108,26%0,01%0,00%
112,86%0,00%0,00%
120,60%0,00%0,00%
130,06%0,00%0,00%
Total100%100%100%

<colgroup><col><col span="7"></colgroup><tbody>
</tbody>
 
Upvote 0
Hi Kishan


Each % number is a character 1 X 2 and if I make a row with the 13 biggest % numbers I can see on the prediction table how many right it should be in that row. Then I do the same with the second largest and the same with the smallest. These 3 lines I put into a program and put the conditions on each line (6-9 right.1-5 right.1-4 right) which I colored. These 3 rows of the terms I set reduces the 1 594 323 lines to 300 872 rows.
This can be a basis when you are going to reduce but then you can continue with several conditions to get the radtal you want to play.
Hi bilbon, thank you for your </SPAN>patient</SPAN> I am catching a track bit, you are really using a probability % in your programme to eliminate the lines. Can I ask you is it a any free programme? If so please can you provide a link? </SPAN></SPAN>

I know the one but not very familiar with it here is a link you can download it is totally free and reliable too may help you </SPAN></SPAN>
http://www.megaquin1x2.com/</SPAN></SPAN>

Please any other tips I would like to get from you </SPAN></SPAN>

Thank you </SPAN></SPAN>

Regards,</SPAN></SPAN>
Kishan </SPAN></SPAN>
 
Last edited:
Upvote 0
Hi SHG or anyone else


Would there be much change in the code to reverse the table so 13 comes at the top and 0 at the bottom.
I am not so knowledgeable that I can handle it myself.


/Bilbon
 
Upvote 0
Hi Kishan


The programs I use are not free and do not think the little more advanced programs are free.
What you link to is too difficult for me with Spanish but thanks anyway.


/Bilbon
 
Last edited:
Upvote 0
I'm sure it's possible to change shg's UDF to go in the opposite order, but I'll leave that up to shg. In the meantime, you can use that UDF and get the results you want by just changing the formula on the sheet. In column J, put the k values in the order you want. Delete out the formulas from K2:M15. Then in K2 put this formula:

=INDEX(poissonbinom(F$2:F$14),$J2+1)

copy down and across as needed. Somewhat oddly, column K sums to 100%, where it didn't originally. I'll have to look at that.
 
Upvote 0
Somewhat oddly, column K sums to 100%, where it didn't originally.
I think I must have had an error in the sum formula :eek:

I added an option to use either the fast (unstable) method or the slow (more accurate) method. Fast:

A​
B​
C​
D​
E​
F​
G​
H​
I​
J​
K​
L​
M​
1​
Fast
2​
TRUE​
3​
Sorted
k
Pr(k)
Pr(k)
Pr(k)
4​
Match
Win
Draw
Lose
1
2
3
0​
0.000 004 965 618 890​
0.023 945 607 207 981​
0.074 681 273 868 039​
5​
1​
14%​
25%​
61%​
61%​
25%​
14%​
1​
0.000 133 742 200 799​
0.104 848 330 504 405​
0.217 899 673 681 578​
6​
2​
92%​
6%​
2%​
92%​
6%​
2%​
2​
0.001 416 853 003 021​
0.210 233 356 636 269​
0.289 332 167 783 446​
7​
3​
49%​
30%​
21%​
49%​
30%​
21%​
3​
0.008 399 492 726 107​
0.255 402 445 312 009​
0.231 243 609 312 226​
8​
4​
50%​
27%​
23%​
50%​
27%​
23%​
4​
0.032 028 692 277 197​
0.209 544 750 787 826​
0.123 943 684 241 114​
9​
5​
69%​
20%​
11%​
69%​
20%​
11%​
5​
0.084 242 187 404 515​
0.122 468 272 545 888​
0.046 962 991 654 853​
10​
6​
48%​
30%​
22%​
48%​
30%​
22%​
6​
0.158 674 700 986 833​
0.052 380 939 169 867​
0.012 911 869 631 450​
11​
7​
48%​
30%​
22%​
48%​
30%​
22%​
7​
0.217 987 541 603 344​
0.016 569 626 657 441​
0.002 599 892 845 129​
12​
8​
49%​
28%​
23%​
49%​
28%​
23%​
8​
0.219 323 229 058 714​
0.003 866 932 009 929​
0.000 381 709 007 839​
13​
9​
56%​
25%​
19%​
56%​
25%​
19%​
9​
0.160 095 690 495 266​
0.000 655 322 787 878​
0.000 040 092 829 492​
14​
10​
28%​
29%​
43%​
43%​
29%​
28%​
10​
0.082 600 611 102 899​
0.000 078 001 030 912​
0.000 002 897 732 972​
15​
11​
64%​
22%​
14%​
64%​
22%​
14%​
11​
0.028 577 327 922 008​
0.000 006 128 456 875​
0.000 000 133 961 486​
16​
12​
67%​
19%​
14%​
67%​
19%​
14%​
12​
0.005 950 949 314 411​
0.000 000 281 325 450​
0.000 000 003 417 567​
17​
13​
19%​
30%​
51%​
51%​
30%​
19%​
13​
0.000 564 015 896 089​
0.000 000 005 567 271​
0.000 000 000 032 809​
18​
Total
0.999 999 999 610 092​
1.000 000 000 000 000​
1.000 000 000 000 000​

Formula in K4:K17: =TRANSPOSE(PoissonBinom(F5:F17, $K$2))

Slow:

A​
B​
C​
D​
E​
F​
G​
H​
I​
J​
K​
L​
M​
1​
Fast
2​
FALSE​
3​
Sorted
k
Pr(k)
Pr(k)
Pr(k)
4​
Match
Win
Draw
Lose
1
2
3
0​
0.000 004 965 618 890​
0.023 945 607 207 981​
0.074 681 273 868 039​
5​
1​
14%​
25%​
61%​
61%​
25%​
14%​
1​
0.000 133 742 200 799​
0.104 848 330 504 405​
0.217 899 673 681 578​
6​
2​
92%​
6%​
2%​
92%​
6%​
2%​
2​
0.001 416 853 003 021​
0.210 233 356 636 269​
0.289 332 167 783 446​
7​
3​
49%​
30%​
21%​
49%​
30%​
21%​
3​
0.008 399 492 726 107​
0.255 402 445 312 009​
0.231 243 609 312 226​
8​
4​
50%​
27%​
23%​
50%​
27%​
23%​
4​
0.032 028 692 277 197​
0.209 544 750 787 826​
0.123 943 684 241 114​
9​
5​
69%​
20%​
11%​
69%​
20%​
11%​
5​
0.084 242 187 404 516​
0.122 468 272 545 888​
0.046 962 991 654 853​
10​
6​
48%​
30%​
22%​
48%​
30%​
22%​
6​
0.158 674 700 986 832​
0.052 380 939 169 867​
0.012 911 869 631 450​
11​
7​
48%​
30%​
22%​
48%​
30%​
22%​
7​
0.217 987 541 603 338​
0.016 569 626 657 441​
0.002 599 892 845 129​
12​
8​
49%​
28%​
23%​
49%​
28%​
23%​
8​
0.219 323 229 058 589​
0.003 866 932 009 929​
0.000 381 709 007 839​
13​
9​
56%​
25%​
19%​
56%​
25%​
19%​
9​
0.160 095 690 494 111​
0.000 655 322 787 878​
0.000 040 092 829 492​
14​
10​
28%​
29%​
43%​
43%​
29%​
28%​
10​
0.082 600 611 084 913​
0.000 078 001 030 912​
0.000 002 897 732 972​
15​
11​
64%​
22%​
14%​
64%​
22%​
14%​
11​
0.028 577 327 748 556​
0.000 006 128 456 875​
0.000 000 133 961 486​
16​
12​
67%​
19%​
14%​
67%​
19%​
14%​
12​
0.005 950 947 970 558​
0.000 000 281 325 450​
0.000 000 003 417 567​
17​
13​
19%​
30%​
51%​
51%​
30%​
19%​
13​
0.000 564 017 822 574​
0.000 000 005 567 271​
0.000 000 000 032 809​
18​
Total
1.000 000 000 000 000​
1.000 000 000 000 000​
1.000 000 000 000 000​

Revised code:

Code:
Function PoissonBinom(rProb As Range, Optional bFast As Boolean = True) As Variant
  ' shg 2018
  ' UDF wrapper for adPoissonBinom

  Dim p()           As Double
  Dim cell          As Range
  Dim i             As Long

  With rProb
    ReDim p(1 To .Cells.Count)
    For Each cell In .Cells
      If VarType(cell.Value2) = vbDouble Then
        If cell.Value2 > 0# And cell.Value2 < 1# Then
          i = i + 1
          p(i) = cell.Value2
        Else
          PoissonBinom = "0 < p < 1! " & cell.Address(False, False)
          Exit Function
        End If
      Else
        PoissonBinom = "Non-numeric: " & cell.Address(False, False)
        Exit Function
      End If
    Next cell
  End With

  If bFast Then PoissonBinom = adPoissonBinom2(p) Else PoissonBinom = adPoissonBinom1(p)
End Function

Private Function adPoissonBinom1(p() As Double) As Double()
  ' shg 2018
  ' VBA only

  ' https://en.wikipedia.org/wiki/Poisson_binomial_distribution#Probability_mass_function
  ' the slow, more accurate method

  Dim n             As Long
  Dim Pr()          As Double
  Dim i             As Long
  Dim j             As Long
  Dim k             As Long
  Dim aiC()         As Long
  Dim A()           As Boolean

  n = UBound(p)

  ReDim Pr(0 To n)
  ReDim T(1 To n)

  Pr(0) = 1#

  For i = 1 To n
    Pr(0) = Pr(0) * (1# - p(i))
  Next i

  For k = 1 To n
    ReDim aiC(1 To k)
    aiC(1) = -1

    Do While bNextCombo(aiC, n)
      ReDim A(1 To n)
      For i = 1 To k
        A(aiC(i) + 1) = True
      Next i

      Dim d         As Double
      d = 1#
      For i = 1 To n
        If A(i) Then d = d * p(i) Else d = d * (1 - p(i))
      Next i
      Pr(k) = Pr(k) + d
    Loop
  Next k

  adPoissonBinom1 = Pr
End Function

Private Function adPoissonBinom2(p() As Double) As Double()
  ' shg 2018
  ' VBA only

  ' https://en.wikipedia.org/wiki/Poisson_binomial_distribution#Probability_mass_function
  ' the fast, lesss numerically stable method

  Dim n             As Long
  Dim Pr()          As Double
  Dim T()           As Double
  Dim i             As Long
  Dim j             As Long
  Dim k             As Long

  n = UBound(p)

  ReDim Pr(0 To n)
  ReDim T(1 To n)

  Pr(0) = 1#

  For i = 1 To n
    Pr(0) = Pr(0) * (1# - p(i))
    For j = 1 To n
      T(i) = T(i) + (p(j) / (1# - p(j))) ^ i
    Next j
  Next i

  For k = 1 To n
    For i = 1 To k
      Pr(k) = Pr(k) + (-1) ^ (i - 1) * Pr(k - i) * T(i) / k
    Next i
  Next k

  adPoissonBinom2 = Pr
End Function

The slow routine requires this:

Code:
Public Function bNextCombo(aiC() As Long, n As Long) As Boolean
  ' shg 2009-12
  '     2011-07 (modified to require aiC(1) < 0 to initialize)

  ' VBA only

  ' Sets aiC to the next combination of n choose m in lexical order
  ' Returns True unless the combination is the last, in which case
  ' it leaves aiC unmodified.

  ' If aiC(1) < 0, initializes aiC to the first combo:
  '                   {m-1,  m-2, ...,     1,   0}
  ' The last combo is {n-1,  n-2, ..., n-m+1, n-m}

  Dim m             As Long
  Dim i             As Long

  m = UBound(aiC)
  If n < m Then Exit Function

  If aiC(1) < 0 Then    ' set initial combo
    i = 1
    aiC(1) = m - 2

  Else

    ' find rightmost incrementable index
    For i = m To 2 Step -1
      If aiC(i) < aiC(i - 1) - 1 Then Exit For
    Next i
  End If

  If i <> 1 Or aiC(1) < n - 1 Then
    ' increment that index, and set 'righter' indices descending to 0
    aiC(i) = aiC(i) + 1
    For i = i + 1 To m
      aiC(i) = m - i
    Next i

    bNextCombo = True
  End If
End Function
 
Last edited:
Upvote 0
H, Eric and shg


Thanks to both of you for your help, I am so grateful, your suggestions work great

/Bilbon
 
Upvote 0

Forum statistics

Threads
1,213,496
Messages
6,113,995
Members
448,539
Latest member
alex78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top