0

$A$ is a multiset $\{x_1, \cdots, x_1, x_2, \cdots, x_2, \cdots, x_j\}$ which has different objects $x_1, x_2,\cdots, x_j$ and the number of $x_i$ is $n_i$ ($\sum_{i=1}^{j} n_i = N$)

How many different $k$-size multi-subset of $A$?

I know it should be equivalent to find number of integer solutions of

$$a_1 + a_2 + \cdots + a_j = k$$ with constraints $0 \le a_i \le n_i$.

for example: $A = \{1,1,2,2,2\}$, $3-$size multi-subsets are $\{1,1,2\}$, $\{1,2,2\}$, $\{2,2,2\}$.

Is there an analytical solution of above question, which depends on $n_1, \cdots, n_j, k$? I mean that it's similiar to Catalan Number, Bell Number or Stirling number which can be written as formula of binomial coefficients/multinomial coefficients. Thanks.

Asaf Karagila
  • 393,674
maplemaple
  • 1,211
  • what do you mean analytical? It can be done with dynamic programming, what sort of complexity are you aiming for? I don't think there is a pretty closed form expression. – Asinomás Apr 28 '21 at 01:08
  • @HereToRelax Similiar to Catalan Number, Bell Number or Stirling number which can be written as formula of Binomial coefficients/multinomial coefficients. – maplemaple Apr 28 '21 at 01:13
  • Catalan numbers and bell numbers only have one parameter though. – Asinomás Apr 28 '21 at 01:15
  • @HereToRelax I know. Therefore it may be written as formula of Multinomial coefficient, which as parameter $n_1, n_2, \cdots, n_j$. – maplemaple Apr 28 '21 at 01:19
  • I think the approach with generating functions yields a not very pretty inclusion exclusion with exponential complexity using binomial coefficients. Although the dynamic programming approach yiels $\mathcal O(k)$ memory and $\mathcal O(jk)$ time, which I think is pretty good. – Asinomás Apr 28 '21 at 01:59

0 Answers0