Assign probabilities to output in Python? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

Assign probabilities to output in Python?

There are two teams in a soccer match. Team A has a 70 % probability of winning, a draw is 25 %, team B has a 5 % of the winning. How can you derive a score (e.g. 1:0) based on these probabilities? Assume that the goals are a random integer between 1 and 5.

5th May 2018, 1:52 PM
Johannes
Johannes - avatar
13 Answers
+ 8
I tried a bit different approach, take a look: https://code.sololearn.com/c9m4le17wggx/?ref=app
5th May 2018, 2:38 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 5
It would depends on how many times you want to roll the dice in a specific match. 😉 The problem a little bit vague as you can always assign the winning team with any score as long as it's at least one more than the opposing team.
5th May 2018, 2:07 PM
Zephyr Koo
Zephyr Koo - avatar
+ 5
tamaslud It is because the odds provided in the task concerned the ultimate result only. It is not the chance of striking a goal in a match, but of winning the match. Theoretically, to be 100% correct with the task, we could first determine the winner (or a draw) with the set 0.70/0.05/0.20 probability and then randomly pick the result from all possible ones: (0:0, 1:1, 2:2,... 5:5) for draws, (1:0, 2:0, 3:0,... 5:3, 5:4) for A and (0:1, 0:2,... 3:5, 4:5) for B. Still, the task is too vague about the match results, to determine whether it is a good approach.
5th May 2018, 3:53 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 5
Johannes Thanks! I also felt it as being a more real-life example than going "backwards" from the result to the score :)
5th May 2018, 5:06 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 3
Johannes They should hover around 0.70/0.05/0.25, respectively. The task is too vaguely coined to be able to solve it in only one way, as it leaves a lot of space for interpretation :)
5th May 2018, 3:16 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 2
i think you also need the probability of a particular amount of goals per match. e.g. 100% is the probability of a draw. it can be either 0:0 or 30:30 if the number of goals are not determinated some way
5th May 2018, 2:22 PM
tamaslud
tamaslud - avatar
+ 2
Kuba Siekierzyński - getting there :) Next step will be determining the odds from relative team strength. It's really a fun project. https://code.sololearn.com/cjNkd8F0FSVB/?ref=app
5th May 2018, 8:58 PM
Johannes
Johannes - avatar
+ 2
It's done! The probability part works :) https://code.sololearn.com/cjNkd8F0FSVB/?ref=app
8th May 2018, 2:57 PM
Johannes
Johannes - avatar
+ 1
Kuba Siekierzyński - this is a very interesting approach. Thanks!
5th May 2018, 3:03 PM
Johannes
Johannes - avatar
+ 1
Kuba Siekierzyński - from glancing over it, it seems that the %es of the crown outcomes are also curved around the preset odds. But at what probability, I ask :)
5th May 2018, 3:08 PM
Johannes
Johannes - avatar
+ 1
Kuba Siekierzyński in your code it is 0.72/0.12/0.16 but the result is ok. how it happens?
5th May 2018, 3:34 PM
tamaslud
tamaslud - avatar
+ 1
Kuba Siekierzyński -still, I really think your approach is very good and usable. Thanks a lot for all the help and great input!
5th May 2018, 4:43 PM
Johannes
Johannes - avatar
+ 1
Kuba Siekierzyński - and I much prefer it to the other, theoretically more correct one. Makes more sense for a soccer game :)
5th May 2018, 4:45 PM
Johannes
Johannes - avatar