Counting sentences with a specific letter profile

78 Views Asked by At

Suppose that we have an alphabet of size $L$ and for a given $\phi=(\phi_1, \phi_2,..., \phi_n)$, we want to count the number $S$ of sentences from $L^n$ in which, for every $k$, the number of letters that appear $k$ times equals $\phi_k$. For example, if $L=\{a, b\}$ and $\phi=(1, 1, 0)$, then the number of sentences from $\{a,b\}^3$ that have one letter appearing once and one letter appearing twice is $S=6$ ($aab, aba, abb, baa, bab, bba$). Similarly, if $\phi=(0, 0, 1)$, then this number equals $S=2$ ($aaa, bbb$).

I am wondering if there is a closed formula for $S$ and in case there is not, or it is really messy, can we at least deduce how $S$ depends on $L$ ? For example, for $\phi=(3,2,0,0,0,0,0)$, I get the following for $S=S(L)$: $S(1)=S(2)=S(3)=S(4)=0, S(5)=12600, S(6)=75600, S(7)=264600, S(8)=705600, S(9)=1587600$.

EDIT: It looks like $S(L) = c\times \frac{L!}{(L-m)!}$ where $m$ is the minimum number of letters there must be in the alphabet for the given profile $\phi$ to be valid, i.e. $m=\sum \phi_k$.

1

There are 1 best solutions below

0
On BEST ANSWER

Let $X$ be the number of distinct alphabet in the sentence, i.e. $X=\sum_{i=1}^n \phi_i$ and $Y$ be the length of the sentence, i.e. $Y=\sum_{i=1}^n i\phi_i$.

Then, if $L\geq X$, the number of ways of forming a sentence of length $Y$ with given $X$ distinct alphabets. We have

$$\binom{X}{\phi_1,\phi_2,\ldots,\phi_n}\frac{Y!}{\prod_{i=1}^n(i!)^{\phi_i}}$$.

Also, the number of ways to choose $X$ alphabets from a set of size $L$ equals $\binom{L}{X}$.

$$\therefore S(L, \phi)=\binom{L}{X}\cdot \binom{X}{\phi_1,\phi_2,\ldots,\phi_n}\frac{Y!}{\prod_{i=1}^n(i!)^{\phi_i}}$$