I know that the formula for counting the number of ways in which $n$ indistinguishable balls can be distributed into $k$ distinguishable boxes is $$\binom{n + k -1}{n}$$
but I am having a hard time understanding why this formula counts that. I mean, suppose we have $4$ boxes and $3$ balls, then the problem is equivalent to count the permutations of 5 vertical lines with 3 circles except that two lines have to be fixed (the first and last lines). I would appreciate if someone could help me to relate and translate this way of thinking the problem to the formula with this. Thanks in advance.
This is the "Stars and bars" problem, which we may see as follows: Assume stars $*$ represent the balls and $\\|$ represent an end side of a box. $$ \underbrace{*\ *\ *\ \ \ \ \ \ *}_{n\ balls}\ \ \ \underbrace{[ \ \vert \ \vert \ \vert \ \vert \ \ \ \ \vert \ \vert \ ]}_{k \ boxes}^{k-1\ bars} $$ Take two of the bars as special, to represent left and right ends. Then the original problem may be reformulated : How many different combinations of these $n+k-1$ objects there are? This is $$ {(n+k-1)!\over n!\cdot (k-1)!} = \binom{n+k-1}{n} $$