Using RStudio to find the probability of who wins a soccer match?

296 Views Asked by At

Team A on average scores 2.1 goals/match, Team B on average scores 1.6 goals/match. Using R simulate 1000 realisations of the match and estimate the probability of team A winning, team B winning and the probability of a tie.

So far I have found 1000 simulations for how many goals each team would score in each mach using:

queueA = rpois(lambda=2.1, n=1000) & queueB = rpois(lambda=1.6, n=1000)

But am having problems marrying up the scores for each game and thus finding the required probabilities.

1

There are 1 best solutions below

1
On BEST ANSWER

Hint: If you have two vectors queueA and queueB in $\texttt{R}$, try typing

sum(queueA > queueB)

That should return the number of elements in queueA that are greater than the corresponding element in queueB. You can use this to find the number of games where A beat B.