How many sequences with $k$ different values less than $d$?

58 Views Asked by At

Pick $\ell$ elements of $\{1,\dots,n\}$ with replacement ($n^\ell$ different ways to do that).

Given $k\leq \ell$ and $d\leq n$, in how many cases will you have exactly $k$ different values $\leq d$?

Note that values greater than $d$ are allowed, as long as there are exactly $k$ values less than or equal to $d$. I am not requiring that there only be $k$ values and all those be less than or equal to $d$.

1

There are 1 best solutions below

0
On

This will be a fair mess to compute. You can pick the specific $k$ values in $d \choose k$ ways. Now pick $m$, the number of elements less than $d$. For each $m$, you can pick the positions in the list in $n \choose m$ ways, the values of those positions in $k^m$ ways and the values of the other positions in $(\ell-m)^{(n-d)}$ ways. This gives the number of ways to have at most $k$ different values less than $d$ as $$\sum_{m=k}^\ell {d \choose k}{n \choose m}k^m(\ell-m)^{(n-d)}$$ Unfortunately, we have counted the ones with exactly $k-1$ values $d-k+1$ times each, so we need to subtract them. There are $$\sum_{m=k-1}^\ell {d \choose k-1}{n \choose m}(k-1)^m(\ell-m)^{(n-d)}$$ of these. Then we continue with those with $k-2$ values, following the inclusion-exclusion principle.