permutation of a subset from a set with multiple repetitions Suppose I have an urn with 20 tokens which has 10 different colors and each color appears exactly twice. These token are are non distinct except their color. The question is in how many different arrangements of 10 can be made from these above mentioned 20 tokens?
How would be solve the generalized version of this problem: An urn contains $\sum_{i=1}^{n}a_{i}$ tokens in all, of which $a_1$ of them are of the first color, $a_2$ of them are of the second color and  $a_n$ of them are of the $n^{th}$ color, then in how many ways can we arrange $m$ token chosen from this urn?
 A: There is no formula, but there is a method to compute the number of ways using a recursive procedure and a computer. As I mentioned in the comments, this question has been asked many times before on this site, but I have never taken the time to write out this simple method.
For each $k\in \{1,2,\dots,n\}$, and each $j\in \{0,1,\dots,m\}$, let
$$
A(k,j)=
\begin{matrix}
\text{number of arrangements of $j$ items from an urn with $k$ colors of tokens,}\\\text{with $a_1$ tokens of the first color, $a_2$ of the second color, ... , $a_k$ of the $k^{th}$ color}
\end{matrix}
$$
The answer to your problem is $A(n,m)$, while $A(k,j)$ is a simpler problem for $k<n$ and $j<m$. These subproblems satisfy the following recursive equation:
$$
A(k,j) = \sum_{i=0}^{\min(j,a_k)} \binom{j}{i}A(k-1,j-i)\\
A(1,j)=\begin{cases}1 & 0\le j\le a_1 \\ 0 & a_i< j\end{cases}
$$
The idea is that in order to count the number of arrangements of $j$ items using the first $k$ colors, you consider all the possibilities for the number of times color $k$ is chosen. If color $k$ appears $i$ times, then you can place those $i$ tokens in the sample in $\binom ji$ ways, and then fill in the remaining $j-i$ spots with the first $k-1$ colors in $A(k-1,j-1)$ ways.
This recursive equation lets you compute $A(n,m)$ by filling out a $(n+1)\times m$ dynamic programming table, whose entry in the $k^{th}$ row and $j^{th}$ column is $A(k,j)$. Since there are $O(mn)$ entries, and each entry is a summation of $O(m)$ terms, the time this takes is $O(m^2n)$. The time this takes gets unwieldly pretty quickly. For a faster method, you would instead have to use exponential generating functions, using FFT multiplication to multiply the polynomials. For more details, see my other answer here.
A: You have N objects, some are identical. Label them (1,1) through (N,m) where the first component is just the kth object and the second component is the jth class. |j| = size of the jth class.
There are clearly N! ways to order these N objects. The problem is that some the same so some of these orderings will be identical and so we have to remove them.
Say you have Red_(1,1) Blue_(2,2) Green_(3,3) Red_(4,1)
This arrangement is the same as Red_(4,1) Blue_(2,2) Green_(3,3) Red_(1,1)
If we ignore the class info then we have Red_1 Blue_2 Green_3 Red_4 and Red_4 Blue_2 Green_3 Red_1 and these are different than the fully distinguishable case. Hence we "double counted".
If we ignore the distinguishing indexing then we Red_1 Blue_2 Green_3 Red_1 or just Red Blue Green Red.
Now if we index them we actually have $N = \sum a_i$ total distinguishable objects and so N! possible combinations. But now we have to remove "extras" due to collapsing to classes. In the above example, Red_(1,1) and Red_(4,1) are different and but they are also the same. How are they the same? We can swap them. There are 2! ways to swap. So we must remove 2!. If we had 3 reds(a_1 = 3) then we could form 3! different distinct strings or remove 3! to collapse them.
The way I think about this removable is that we collapse down all the same class objects to one object but that object exists in "multiple places" due to the original arrangement order. E.g., what I showed above. E.g., say we have RBGRRGRBBRRG but we also have RBGRRGRBBRRG, RBGRRGRBBRRG, RBGRRGRBBRRG, RBGRRGRBBRRG, RBGRRGRBBRRG, RBGRRGRBBRRG, RBGRRGRBBRRG, RBGRRGRBBRRG, etc. Yes, these are all the same! NO THEY ARE NOT ALL THE SAME! YES THEY ARE! If you just think of "how many ways can I fill the R's with my a_R marbles, well, there are a_R! ways. Same goes for each of the other colors. But when we combine them we have to multiply to get all the possible combinations. If you are just dealing with R's then you can ignore the B and G's for now so that RBGRRGRBBRRG -> RRRRRR. So we have 6 R's that we can fill in with our 6 red marbles. If we ordered our marbles then that would be 6! ways to arrange them. RBGRRGRBBRRG -> BBB and so we can arrange our 3 blue marbles 3! ways and RBGRRGRBBRRG -> GGG also has 3!. Combined though this means we have 6!*3!*3! distinguishing combinations(and to go the opposite way we have to remove these).
This is an easier problem than if we are given, say, a pattern like RGRRGB and have 10 reds, 34 greens, and 8 blue marbles and asked how many distinguished combinations can we form. Well, only slightly more difficult. We have 3 spots for our red marbles and have 10 so we have 10C3, then 24C2 and 8C1. Then multiply together to get all combinations. But that was just for RGRRGB, we then might have RRGGBR and all other arrangements for those sequences(which is a sort of separate problem).
So you end up with $$\frac{(\sum a_i)!}{\prod a_i!}$$
Note that if they are all distinguishable then you just have $N!$. Imagine you have 2 classes of x and y elements. This means you have a total of $(x+y)!$ ways to order them if you treat the elements as distinct. Once you have those combinations you have over counted by x! and y! ways(for a total of x!*y!).
