Premium problem93. How Many Categories Do You See?

Medium Locked

Draw n times with replacement from m equally likely categories. Return the expected number of distinct categories you end up seeing.

Do not try to count subsets. Give each category an indicator for "was seen" and add the expectations:

E=m(1−(1−1m)n)E = m\left(1 - \left(1 - \tfrac{1}{m}\right)^{n}\right)

Linearity of expectation does not care that the indicators are dependent, which is what makes this one line instead of a summation over cases.

Input

n = 10
m = 10

Output

6.513215599

Premium problem

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

Implement solve(...)