TITLE: Unordered sampling with replacement
QUESTION [8 upvotes]: I have difficulties with understanding of how do we count this.

Why can't we just divide number of ways of ordered sample with replacement $n^k$ by $k!$, i.e. to get rid of permutations since we cannot distinguish elements? What so different about that in comparison to the case without replacement?
I read the derivation based on counting "walls" between integers representing number of times particular ball was drawn. I do understand how to count number of combinations in this case but I do not understand how we get there, namely, why these numbers (number of combinations of placing "walls" and number of unordered samples with replacement) are the same?

REPLY [7 votes]: As regards 1):
Consider n=2, k=2. There are 3 possibilities to count: 00, 01, 11. That is not $2^2/2! = 2$; the "why" of it being that not every permutation of an ordered sampling yields a different ordered sampling. The assumption that there are 2! possible permutations of 01 is correct; but there are not 2! permutations for 00, there is instead only 1. So $\frac{n^k}{k!}$ undercounts the number of outcomes.
As regards 2):
Not exactly sure what you're referring to as "walls between integers", but assuming you mean something like the usual "stars and bars" approach... Given a set $\{a_1, a_2, ..., a_n\}$ that we are sampling from with replacement, each possible unordered sampling with replacement can be thought of as "there are $m_1$ samples that are $a_1$, $m_2$ samples that are $a_2$, ..., $m_n$ samples that are $a_n$" where we know that each $m_i \geq 0$ and $\sum m_i = k$. 
But that is the same thing we are looking at when we want to count the number of ways we can distribute $k$ objects into $n$ bins; $m_i$ is the number of samples we have allocated to bin $i$. So the function which counts the former should be identical to the function that counts the latter.