2

Say I got $n$ m-faced dices, each dice has value 1 to $m$ on one of the sides.

Now after one throw, what is the probability of getting exactly $k$ different values ?

For eg, Let $n = 7, m = 5, k = 3$,

Then ${1,2,3,3,3,3,3}$ or $3,3,5,2,5,3,5$ is a desired result as both set consists 3 different values

shole
  • 173
  • 2
    Start off with this instead - how can you distribute $n$ indistinguishable objects among $k$ people? Do you see how this helps? –  Sep 22 '17 at 10:37
  • Also, what are your own thoughts about the question? –  Sep 22 '17 at 10:37
  • I am not familiar but is that similar to multinomial like sum of n!/(a!b!...) for any set of a + b + ... = n? – shole Sep 22 '17 at 10:41
  • I also think of inclusive exclusive principle which i can calculate P(<= 1 values), P(<= 2 values)...P(<= k values). Not sure if it is correct direction tho – shole Sep 22 '17 at 10:46

6 Answers6

4

First choose the $k$ different values for a factor of

$${m\choose k}$$

and arrange them in order. Next partition the $n$ rolls into $k$ non-empty subsets, for a factor of

$${n\brace k}.$$

Match the ordered dice values to the sets in

$$k!$$

ways. This makes for a probability of

$$\bbox[5px,border:2px solid #00A000]{ m^{-n} \times {m\choose k} \times {n\brace k} \times k!.}$$

Sum this to see that it is a probability distribution:

$$m^{-n} \sum_{k=1}^m {m\choose k} \times {n\brace k} \times k! \\ = m^{-n} \sum_{k=1}^m {m\choose k} n! [z^n] (\exp(z)-1)^k.$$

With $n\ge 1$ we may include the term for $k=0$ as it does not contribute to $[z^n]$ to get

$$m^{-n} n! [z^n] \sum_{k=0}^m {m\choose k} (\exp(z)-1)^k \\ = m^{-n} n! [z^n] \exp(zm) = 1$$

which confirms it being a probability distibution. We can also compute the expectation which requires

$$m^{-n} \sum_{k=1}^m {m\choose k} n! [z^n] k (\exp(z)-1)^k \\ = m^{-n} n! [z^n] \sum_{k=1}^m {m\choose k} k (\exp(z)-1)^k \\ = m^{-n} n! [z^n] m \sum_{k=1}^m {m-1\choose k-1} (\exp(z)-1)^k \\ = m^{-n} n! [z^n] m (\exp(z)-1) \sum_{k=1}^m {m-1\choose k-1} (\exp(z)-1)^{k-1} \\ = m^{-n} n! [z^n] m (\exp(z)-1) \exp((m-1)z) \\ = m^{-n} n! [z^n] m (\exp(mz)-\exp((m-1)z)) \\ = m \times \left(1 - m^{-n} (m-1)^n\right).$$

We get

$$\bbox[5px,border:2px solid #00A000]{ m \times \left(1 - \left(1-\frac{1}{m}\right)^n\right).}$$

There is also this very basic Maple code that implements these statistics.

with(combinat);

ENUM :=
proc(n, m)
option remember;
local d, mset, idx, gf;

    gf := 0;

    for idx from m^n to 2*m^n-1 do
        d := convert(idx, base, m);
        mset := convert(d[1..n], `multiset`);
        gf := gf + u^nops(mset);
    od;

    gf;
end;

GFX := (n, m) ->
add(u^k*binomial(m,k)*stirling2(n,k)*k!, k=1..m);

PROB := (n,m) -> subs(u=1, GFX(n, m)) / m^n;
EXPT := (n,m) -> subs(u=1, diff(GFX(n, m), u)) / m^n;

EXPT2 := (n, m) -> m*(1 - (1-1/m)^n);

Remark. User @orlp suggests looking at the generating function. Recall that for Stirling numbers of the second kind we have

$$\sum_{n\ge 0} {n\brace k} x^n = \prod_{r=1}^k \frac{x}{1-rx}.$$

We get for the generating function

$$G_k(z) = \sum_{n\ge 1} z^n \times m^{-n} \times {m\choose k} \times {n\brace k} \times k! \\ = \frac{m!}{(m-k)!} \sum_{n\ge 1} m^{-n} z^n [x^n] \prod_{r=1}^k \frac{x}{1-rx} \\ = \frac{m!}{(m-k)!} \prod_{r=1}^k \frac{z/m}{1-rz/m} \\ = \frac{m!}{(m-k)!} \prod_{r=1}^k \frac{z}{m-rz}.$$

This may be re-written as

$$m^{\underline{k}} \prod_{r=1}^k \frac{1}{m/z-r} = m^{\underline{k}} \prod_{r=0}^{k-1} \frac{1}{m/z-1-r} = \frac{m^{\underline{k}}}{(m/z-1)^{\underline{k}}}.$$

G1 := (m, k, mx) ->
add(z^n*binomial(m,k)*stirling2(n,k)*k!/m^n, n=0..mx);

FF := (val, q) -> mul(val-p, p=0..q-1);

G2 := (m, k, mx) ->
convert(series(FF(m,k)/FF(m/z-1,k), z=0, mx+1), polynom);
Marko Riedel
  • 61,317
  • +1 In addition to this answer I posted an answer that finds the generating function $A(x)$ of $n$ as $\frac{(-m)_k}{(1-\frac{m}{x})_k}$ where $(x)_n$ is the Pochhammer symbol. – orlp Sep 22 '17 at 23:27
  • Thank you for the pointer, I found the same result. (+1). – Marko Riedel Sep 23 '17 at 00:14
  • I guess that technically in a universe where I randomly conjectured your formula, that would be a proof, as their generating functions are identical :) – orlp Sep 23 '17 at 00:19
  • Really cool stuff. But is there an elementary mulitnomial approach? I kind of got lost looking for a suitable notation; can't express the general solution. (lost in 'mulitnomial weeds'). – CopyPasteIt Sep 23 '17 at 01:08
1

The equi-probable space to consider is that resulting from considering the dice labelled, i.e. by throwing a die $n$ times and considering the results in sequence.
Call $N(k,m,n)$ the number of ways to obtain exactly $k$ distinct outcomes, from a $m$-face die , in $n$ throws.

Let's start from throwing the first die $n=1$: we can have just $k=1$ (distinct) outcome, and we can obtain that in $m$ ways.

Throwing the second time, either we get the same result as before ($1$ way) or we get a different result ($m-1$ ways). The first case will contribute to $N(1,m,2)$, the second to $N(2,m,2)$.

If upon the $n-1$-th throw we totaled $k$ distinct outcomes, then with the throw $n$ we have $k$ ways to contribute to N(k,m,n) and $m-k$ ways to contribute to $N(k+1,m,n)$.
This leads to the following recurrence $$ \bbox[lightyellow] { N\left( {k,m,n} \right) = k\,N\left( {k,m,n - 1} \right) + (m - k + 1)N\left( {k - 1,m,n - 1} \right) + \left[ {0 = k = n} \right] }$$ where $[P]$ denotes the Iverson bracket

The solution to the recurrence is $$ \bbox[lightyellow] { N\left( {k,m,n} \right) = \left\{ \matrix{ n \cr k \cr} \right\}m^{\,\underline {\,k\,} } = k!\left\{ \matrix{ n \cr k \cr} \right\}\left( \matrix{ m \cr k \cr} \right) }$$ because in fact $$ \eqalign{ & N\left( {k,m,n} \right) = \left\{ \matrix{ n \cr k \cr} \right\}m^{\,\underline {\,k\,} } = k\,\left\{ \matrix{ n - 1 \cr k \cr} \right\}m^{\,\underline {\,k\,} } + (m - k + 1)\left\{ \matrix{ n - 1 \cr k - 1 \cr} \right\}m^{\,\underline {\,k - 1\,} } = \cr & = \left( {k\,\left\{ \matrix{ n - 1 \cr k \cr} \right\} + \left\{ \matrix{ n - 1 \cr k - 1 \cr} \right\}} \right)m^{\,\underline {\,k\,} } = \left\{ \matrix{ n \cr k \cr} \right\}m^{\,\underline {\,k\,} } \cr} $$

And we reach, by another way, to the same conlusion as that already given by Marko Riedel.

Note that ${m \choose k}$ is the number of ways to select $k$ elements out of $n$, and $k!\left\{ \matrix{ n \cr k \cr} \right\}$ is the number of surjections from a set with $n$ elements to a set with $k$ elements.

G Cab
  • 35,272
1

This answer isn't as useful as Marko Riedel's, but I found the generating function. We have

$$f(n, k, m) = \frac{m-(k-1)}{m}f(n-1, k-1, m) + \frac{k}{m}f(n-1, k, m)$$

If we fix $m$ we get $p(n,k)$. Let's write a power series for $p(n,k)$:

$$A_k(x) = \sum_{n=1}^\infty p(n,k)x^n$$

But we know that

$$A_k(x) = p(1, k)x + \sum_{n=2}^\infty \left( \frac{m-(k-1)}{m}p(n-1, k-1) + \frac{k}{m}p(n-1, k)\right)x^n$$ Let's assume $k > 1$ for the above formula, giving $p(1, k) = 0$.

$$A_k(x) = \frac{m-(k-1)}{m}\sum_{n=2}^\infty p(n-1, k-1)x^n +\frac{k}{m}\sum_{n=2}^\infty p(n-1, k)x^n$$ $$A_k(x) = \frac{m-(k-1)}{m}\sum_{n=1}^\infty p(n, k-1)x^{n+1} +\frac{k}{m}\sum_{n=1}^\infty p(n, k)x^{n+1}$$ $$A_k(x) = \frac{m-(k-1)}{m}\cdot xA_{k-1}(x) +\frac{k}{m}\cdot xA_k(x)$$ $$(m- kx)A_k(x) = (m-(k-1))\cdot xA_{k-1}(x) $$

$$A_k(x) = x\frac{m-k+1}{m - kx}A_{k-1}(x) $$

And it should be easy to see that $p(n, 1) = m^{1-n}$, giving:

$$A_1(x) = \sum_{n=1}^\infty m^{1-n}x^n = \frac{mx}{m-x}$$

Giving the final generating function:

$$A_k(x) = \frac{mx}{m - x}\prod_{i=2}^k x\frac{m-k+1}{m-kx} = \frac{(-m)_k}{(1-\frac{m}{x})_k}$$

where $(x)_n$ is the Pochhammer symbol.

orlp
  • 10,508
0

For $i=1,\dots,m$ let $X_i$ take value $1$ if side $i$ shows up and let it take value $0$ otherwise. Then you are looking for $$P(X_1+\cdots X_m=k)$$

Based on symmetry we find that this equals $$\binom{n}{k}P\left(X_1=\cdots=X_k=1\wedge X_{k+1}=\cdots=X_m=0\right)$$

and also: $$\binom{n}{k}P\left(X_1=\cdots=X_k=1\mid X_{k+1}=\cdots=X_n=0\right)P(X_{k+1}=\cdots=X_m=0)$$

It is not difficult to find that $P(X_{k+1}=\cdots=X_m=0)=\left(\frac{m-k}{m}\right)^{n-k}$.

It remains to find the conditional probability which is actually the answer on the following question:

"If $n$ dice having $k$ faces are thrown then what is the probability that all faces show up?"

This is a problem that can be solved with the inclusion/exclusion principle and symmetry.

From here we deal with this new question and for $=1,\dots,k$ let $A_i$ denote the event that face $i$ does not turn up.

Then to be found is: $$1-P(A_1\cup\cdots\cup A_k)$$

First give it a try yourself.

drhab
  • 151,093
0

When I jumped on this question I figured it was not too difficult and some hints would be helpful (see the second section). But now that section is more humorous than useful, as it is really just a 'stream-of-consciousness' display.

With the wonderful answers found here, the counting argument can also be easily 'reversed engineered' (see G Cab's concluding remarks).

The expressions $\left\{ \matrix{ n \cr k \cr} \right\}$ are the Stirling numbers of the second kind and count the number of different equivalence relations with precisely ${\displaystyle k}$ equivalence classes that can be defined on an ${\displaystyle n}$ element set.

Proposition 1: Let $X$ be a finite set with $n$ elements and $Y$ be a finite set with $k$ elements. Then there are $k!\left\{ \matrix{ n \cr k \cr} \right\}$ surjective mappings of $X$ onto $Y$.
Proof
To start, observe that if $f$ is any such surjection, and $\sigma$ is a bijective transformation (permutation) of $Y$ not equal to the identity map, then $\sigma \circ f$ is a different surjective map than $f$. But $f$ also defines an equivalence relation, $\{f^{-1}(y_0)\}$, on $X$ so that $f$ 'factors thru' the corresponding quotient set. It is simple task showing that for any surjection $f$, $\sigma_1 \circ f = \sigma_2 \circ f$ if and only if $\sigma_1 = \sigma_2$. If is also easy to check that any other surjection with the same quotient set as $f$ has the form $\sigma^{`} \circ f$ for some (unique) permutation $\sigma^{`}$. Using the rule of product gives us the desired result.
$\blacksquare$

Proposition 2: Let $X$ be a finite set with $n$ elements and $Y$ be a finite set with $m$ elements. Then there are $ {m \choose k} k!\left\{ \matrix{ n \cr k \cr} \right\}$ mapping of $X$ into $Y$ that 'hit' exactly $k$ elements.
Proof
This follows immediately from proposition 1 and, again, by applying the rule of product. $\qquad \blacksquare$


Counting Hints:

Notation: $\bar j = \{1,2,\dots,j \}$.

There are $m^n$ functions mapping $\bar n$ into $\bar m$.

How many surjective maps are there from $\bar n$ onto $\bar k$?
$\quad$ (this is a 'warm up' exercise).

How many partitions are there of $n$ into $k$ parts?

${\displaystyle m^{n}=\sum _{k_{1}+k_{2}+\cdots +k_{m}=n}{n \choose k_{1},k_{2},\ldots ,k_{m}}}$

For your example, $n = 7, m = 5, k = 3$, we want to count a class of functions including $(1,2,3,3,3,3,3)$. So, $7 = 5 + 1 + 1$, and

$5 + 1 + 1 + 0 + 0 $
$5 + 1 + 0 + 1 + 0 $
$5 + 1 + 0 + 0 + 1 $
$5 + 0 + 1 + 1 + 0 $
$5 + 0 + 1 + 0 + 1 $
$5 + 0 + 0 + 1 + 1 $
etc.

So, $(5) (6) = (5) {4 \choose 2} = 30$ and

$\tag 1 30 {7 \choose 5,1,1,0,0}$

would 'pick up' $(1,2,3,3,3,3,3)$, since it contributes a $1\text{-count}$ to ${7 \choose 1,1,5,0,0}$.

CopyPasteIt
  • 11,366
0

The probability of $n$ $m$-sided dice showing exactly $k$ values.

Let $S(i)$ be the set of rolls of $n$ $m$-sided dice where face $i$ does not show up. Then $$ \begin{align} N(j) &=\sum_{|A|=j}\left|\,\bigcap_{i\in A} S(i)\,\right|\\ &=\binom{m}{j}(m-j)^n\tag1 \end{align} $$ The Generalized Inclusion-Exclusion Principle says that the number of rolls in exactly $m-k$ of the $S(i)$ is $$\newcommand{\stirtwo}[2]{\left\{#1\atop#2\right\}} \begin{align} \sum_{j=0}^m(-1)^{j-m+k}\binom{j}{m-k}N(j) &=\sum_{j=0}^m(-1)^{j-m+k}\binom{j}{m-k}\binom{m}{j}(m-j)^n\tag{2a}\\ &=\sum_{j=0}^m(-1)^{j-m+k}\binom{m}{m-k}\binom{k}{j-m+k}(m-j)^n\tag{2b}\\ &=\sum_{j=0}^k(-1)^{k-j}\binom{m}{k}\binom{k}{j}\,j^n\tag{2c}\\ &=\sum_{j=0}^k\sum_{i=0}^n(-1)^{k-j}\binom{m}{k}\binom{m}{j}\binom{j}{i}\stirtwo{n}{i}\,i!\tag{2d}\\ &=\sum_{j=0}^k\sum_{i=0}^n(-1)^{k-j}\binom{m}{k}\binom{k}{i}\binom{k-i}{j-i}\stirtwo{n}{i}\,i!\tag{2e}\\ &=\sum_{j=0}^{k-i}\sum_{i=0}^n(-1)^{k-j-i}\binom{m}{k}\binom{k}{i}\binom{k-i}{j}\stirtwo{n}{i}\,i!\tag{2f}\\ &=\sum_{i=0}^n(-1)^{k-i}\binom{m}{k}\binom{k}{i}[i=k]\stirtwo{n}{i}\,i!\tag{2g}\\ &=\binom{m}{k}\stirtwo{n}{k}\,k!\tag{2h} \end{align} $$ Explanation:
$\text{(2a)}$: apply $(1)$
$\text{(2b)}$: $\binom{j}{m-k}\binom{m}{j}=\binom{m}{m-k}\binom{k}{j-m+k}$
$\text{(2c)}$: substitute $j\mapsto m-j$
$\text{(2d)}$: $j^n=\sum\limits_{i=0}^n\binom{j}{i}\stirtwo{n}{i}\,i!$
$\text{(2e)}$: $\binom{m}{j}\binom{j}{i}=\binom{k}{i}\binom{k-i}{j-i}$
$\text{(2f)}$: substitute $j\mapsto j+i$
$\text{(2g)}$: $\sum\limits_{j=0}^{k-i}(-1)^j\binom{k-i}{j}=[i=k]$ using Iverson brackets
$\text{(2h)}$: apply the Iverson brackets


Thus, the probability of rolling exactly $n$ $m$-sided dice and showing exactly $k$ values is $$ \bbox[5px,border:2px solid #C0A000]{\frac1{m^n}\binom{m}{k}\stirtwo{n}{k}\,k!}\tag3 $$

robjohn
  • 345,667