How many possible ways to pick n different coloured shirts from the given set?

So I have this question, I have $8$ red shirts $4$ blue shirts ... and so on.

The generalized question would be: Suppose I have $k$ shirts, and they are of $m$ different colours and it's given that $a_i$ denotes the number of shirts of $i$th colour. $1 \leq i \leq m$ and $\sum a_i = k$ .

So in how many ways can I pick $n$ different coloured shirts where $n < m$?

I can solve this by picking any $n$ colours, like suppose $n = 3$ and I have red, blue, green, and yellow shirts,

my answer would $(a_{red} * a_{green} * a_{blue}) + (a_{red} * a_{green} *a_{yellow}) + (a_{green} * a_{blue} * a_{yellow} )$

but is there any general method for a random $n$, where I have don't have to calculate individual combinations?

• Can you solve this problem on your own for $n=1,2$ when e.g. $m=3$, $a_1=2$, $a_2=3$, $a_3=1$? It's a good thing to start "small" and look for patterns. Oct 2 '15 at 12:45
• @drhab , I have changed the question details a bit , adding information , that I can solve for small numbers but I actually want a generalized formula for a random n, m values with $a_1 .. a_m$ already known ? Oct 2 '15 at 14:37
• If I understand you correctly then the colors of the $n$ picked shirts are distinct. Then for any fixed color you can only choose one shirt. There are $m$ shirts so $n$ of them must be elected. There are $\binom{m}{n}$ possibilities for that. Are the shirts that have the same color distinguishable? If not then the answer is just $\binom{m}{n}$. Oct 2 '15 at 14:54
• Correction on former comment: "there are $m$ colors (not shirts) so $n$ of them must be selected.." Oct 2 '15 at 15:10
• @drhab yes they are distinguishable , thats what is creating trouble Oct 2 '15 at 17:27

suppose you need the first n colors . then u can choose it in $a_1.a_2....a_n$ ways. but then you have to choose any n colors. so the no. of ways will be $\sum a_{i_1}a_{i_2}...a_{i_n}$ where $i_k \neq i_l$ whenever $k \neq l$ and sum over possible choices
Let $B_{n,m}$ denote the collection of functions $f:\{1,\dots,n\}\rightarrow\{1,\cdots,m\}$ that are orderpreserving. This in the sense that $i_1<i_2\implies f(i_1)<f(i_2)$.
The number of possibilities equals the following expression:$$\sum_{f\in B_{n,m}}\prod_{i=1}^{n}a_{f\left(i\right)}$$
Special case: if $a_1=\cdots=a_m=r$ then the expression equals $r^n\binom{m}{n}$