Probability question on outcome without replacement, selecting $k$ balls with a different number.

probability

I am having a hard time understanding the following

Experiment 1.7.10:

Consider a box that contains n balls numbered $1, . . . , n$.
First, one ball is selected at random from the box and its number is noted. This ball
is then put back in the box and another ball is selected (it is possible that the same
ball will be selected again). As many balls as desired can be selected in this way.
This process is called sampling with replacement. It is assumed that each of the n
balls is equally likely to be selected at each stage and that all selections are made
independently of each other. Find the probability of each outcome being chosen.

Obtaining Different Numbers. For the experiment in Example 1.7.10,
we shall determine the probability of the event $E$ that each of the k balls that are selected will have
a different number.
If $k > n$, it is impossible for all the selected balls to have different numbers because there are only $n$ different numbers. Suppose, therefore, that $k ≤ n$. The number
of outcomes in the event $E$ is the number of vectors for which all $k$ components are
different. This equals $P_{n,k}$, since the first component $x_1$ of each vector can have $n$ possible values, the second component $x_2$ can then have anyone of the other $n−1$ values,
and so on. Since $S$ is a simple sample space containing $n^k$ vectors, the probability $p$
that $k$ different numbers will be selected is
$$p=\cfrac{P_{n,k}}{n^k}=\cfrac{n!}{(n-k)!n^k}$$.

I understand the $p=\cfrac{1}{n^k}$ part but not the rest.

Best Answer

As mentioned the number of ways to choose $k$ balls with the condition all being different is given by $P_{n,k} = \frac{n!}{(n-k)!}$. The answer does a pretty good job explaining why this is the case. Indeed we can draw any ball at the beginning so we have $n$ choices. After we return the ball we want to draw any of the other $n-1$ balls so we have $n-1$ choices. Similarly for the third ball there are $n-2$ choices and so on. So we get that the number of "good" draws is:

$$n \cdot (n-1) \cdot (n-2) \cdots (n-k+1) = \frac{n!}{(n-k)!} = P_{n,k}$$

On the other side there are $n^k$ possible draws. Thus the probability of getting different balls is:

$$p = \frac{P_{n,k}}{n^k} = \frac{n!}{(n-k)!n^k}$$