70 coloured balls are placed in an urn, 10 for each of the seven rainbow colours.
What is the expected number of distinct colours in 20 randomly picked balls?
Give your answer with nine digits after the decimal point (a.bcdefghij).
The expected value of the number of distinct colours is the sum of the expected value of each colour getting picked, which is equal to one minus the probability that the colour hasn't been picked.
from functools import reduce
import operator
def p493():
p = reduce(operator.mul, [(41+i)/(61+i) for i in range(10)], 1)
return 7 * (1 - p)
Or a lightly more general solution:
from math import comb as C
def p493(n=70, m=20):
assert n % 7 == 0
return 7 * (1 - C(n - n // 7, m) / C(n, m))
6.818741802