I'm wondering if someone can give the analytical solution to this problem:
- You start with a single die.
- You roll the die, if the result is <5 then you lost the die while if the result is >= 5 you gain an extra die such that you now have 2 dice.
- You continue rolling all your dice one by one until you have no die left.
For clarity: Say you have 2 dice now, you roll one of them and get 4. Since 4<5 you lost that die and are left with a single die. If you were to get a 6, you will get an extra die such that you now have 3 dice. The game ends when you are left with no die.
All the dice have uniform probabilities of getting 1-6. Let $X$ be the random variable representing how many rolls you did. What is $E[X]$ and $Var[X]$?
Two possible sequence of the number of dice that you have is: 1 2 1 0 (you rolled 3 times) and 1 2 3 2 1 0 (you rolled 5 times).
I've done simulation in R which suggests that $E[X]=3$ and $Var[X]=24$, but I can't seem to prove this analytically. My simulation code is as follows:
library(purrr)
set.seed(102)
number_of_simulation <- 10^6
roll <- 0
number_of_dice <- 1
simulation_number <- 1
simulation_result <- c()
for(simulation_number in 1:number_of_simulation){
while (number_of_dice>0){
roll <- roll + number_of_dice
roll_result <- rdunif(number_of_dice,1,6)
number_of_dice <- 2*sum(roll_result>4)
}
simulation_result[simulation_number] <- roll
simulation_number <- simulation_number + 1
roll <- 0
number_of_dice <- 1
}
mean(simulation_result)
var(simulation_result)
Note
This problem arises from "Dice & Fold", a game released in 2Q24 on Steam. The starting character is called Jack. His skill is to roll 2 dice given that you can provide him with a die greater than 4. There exists a trinket in the game that gives you +2 heal whenever you use a skill. The expected value of the heal amount we get if we use all our dice for this skill is $2E[X]$ times the number of dice that we have at the beginning of the round. Thus, this problem.