Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
6
Task/Dice-game-probabilities/R/dice-game-probabilities.r
Normal file
6
Task/Dice-game-probabilities/R/dice-game-probabilities.r
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
probability <- function(facesCount1, diceCount1, facesCount2, diceCount2)
|
||||
{
|
||||
mean(replicate(10^6, sum(sample(facesCount1, diceCount1, replace = TRUE)) > sum(sample(facesCount2, diceCount2, replace = TRUE))))
|
||||
}
|
||||
cat("Player 1's probability of victory is", probability(4, 9, 6, 6),
|
||||
"in the first game and", probability(10, 5, 7, 6), "in the second.")
|
||||
Loading…
Add table
Add a link
Reference in a new issue