Premium problem95. Expected Largest Roll

Medium Locked

Roll an m-sided die n times. Return the expected value of the largest roll.

Easiest through the tail sum. The maximum is at least v unless every roll came in below it:

E[max⁡]=∑v=1mP(max⁡≥v)=∑v=1m(1−(v−1m)n)E[\max] = \sum_{v=1}^{m} P(\max \geq v) = \sum_{v=1}^{m}\left(1 - \left(\tfrac{v-1}{m}\right)^{n}\right)

Input

n = 2
m = 6

Output

4.472222222222222

Premium problem

This one's part of Premium. Unlock the full Probability track plus every other premium problem on the site.

Implement solve(...)