aez-notes

Trials until First Success

On the average, how many times must a die be thrown until one gets a 6?

The probability that the first six occurs on throw number \(n\) is

\[ \frac{1}{6}\left(\frac{5}{6}\right)^{n-1} \]

This is just the geometric distribution, so we could look up the answer (it is \(6\) in this case), but instead let's see how we can do it in maxima.

load(simplify_sum);

expected_number_rolls: sum(n * p * (1-p)^(n-1), n, 1, inf);
print(simplify_sum(subst(1/6, p, expected_number_rolls)));

The load function is used to laod the simplify_sum function from the solve_rec package.

Author: Alex Zarebski

Created: 2022-04-15 Fri 12:29

Validate