Background
$\newcommand\ms[1]{\mathsf #1}\def\msP{\ms P}\def\msS{\ms S}\def\mfS{\mathfrak S}$Suppose I have $n$ marbles of $c$ colors, where $c≤n$. Let $n_i$ denote the number of marbles of color $i$.
Let $\msP=(1^{n_1} 2^{n_2} \dots c^{n_c})$ be the multiset $\small\{\underbrace{1, \dots, 1}_{n_1},\underbrace{2,\dots,2}_{n_2},\dots,\underbrace{c,\dots,c}_{n_c}\}$ in frequency representation.
The number of distinct permutations of $\msP$ is given by the multinomial: $$\left|\mfS_{\msP}\right|=\binom{n}{n_1,n_2,\dots,n_c}=\frac{n!}{n_1!\,n_2!\cdots n_c!}=n! \prod_{i=1}^c \frac1{n_i!}.$$
Question
How many permutations of $\msP$ have a run of length k?
Let $r_k(\msS)$ be true if a permutation $\msS$ has a run of length $k$ ($k$ marbles in a row are the same color).
For example, if I have 5 marbles (2 green, 2 blue, and 1 yellow), then:
- If $\msS$ is
GBYGB, then $r_1(\msS)$ is true, but $r_2(\msS)$ is false.- If $\msS$ is
GBBYGorGGBBY, then $r_1(\msS)$ and $r_2(\msS)$ are true, but $r_3(\msS)$ is false.Let the number of permutations of $\msP$ having a run of length $k$ be $$N(k; \msP)=\sum\limits_{\msS\in\mfS_\msP}[r_k(\msS)]$$ where $[x]$ denotes the Iverson bracket.
Is there a formula for $N(k; \msP)$?
Essentially, I would like to find a generalization of this recurrence for the case $c=2$ (Bloom 1996).
What I have done so far
I constructed the table below, counting the permutations for configurations of up to $n=7$ marbles by brute force. The rightmost columns count the permutations having runs of length $2≤k≤n$.
Unfortunately, brute force stops being practical around $n\gtrsim 11$ (at $10^8$ permutations; see A005651).
Here is a closer look at the permutations comprising the five $n=4$ cases.
I tried to find patterns along different axes that would lead me to formulas for those specific cases, which I could then generalize, but I haven’t gotten anywhere. I then tried deriving a recurrence relation, also to no avail. My hunch, however, is that there may be a Fibonacci-like recurrence relation involved.
Update
I have entered Andrew’s solution into Mathematica:
Ν[r_, P_] := Multinomial@@P - c[r, P]
c[r_, P_] := CoefficientRules[Π[r, P, t]] /. ({a_} -> b_) :> b a! // Total
Π[r_, P_, t_] := Product[q[r, ni, t], {ni, P}]
a[x_, r_, t_] := a[x, r, t] = Exp[t (x - x^r)/(1 - x^r)]
q[r_, n_, t_] := q[r, n, t] = SeriesCoefficient[a[x, r, t], {x, 0, n}]
The values up to $n=5$ match the tables above:
Column@Table[
Grid@Table[
Table[Ν[r, partition], {r, 1, Max[partition]}
], {partition, IntegerPartitions[marbles]}
], {marbles, 1, 5}
]
1
1 1
2
1 1 1
3 2
6
1 1 1 1
4 4 2
6 4
12 6
24
1 1 1 1 1
5 5 4 2
10 9 3
20 18 6
30 18
60 24
120
Table of $q_{r,n}(t)$ polynomials
$$\newcommand\f[1]{\color{gray}{#1}} \begin{array}{r|llllll} r \backslash n & 1 & 2 & 3 & 4 & 5 & 6 \\ \hline 1 & 0 & 0 & 0 & 0 & 0 & 0 \\ 2 & \f{t} & \frac{t^2}{2}-t & \frac{t^3}{6}-t^2+t & \frac{t^4}{24}-\frac{t^3}{2}+\frac{3 t^2}{2}-t & \frac{t^5}{120}-\frac{t^4}{6}+t^3-2 t^2+t & \frac{t^6}{720}-\frac{t^5}{24}+\frac{5 t^4}{12}-\frac{5t^3}{3}+\frac{5 t^2}{2}-t \\ 3 & \f{t} & \f{\frac{t^2}{2}} & \frac{t^3}{6}-t & \frac{t^4}{24}-t^2+t & \frac{t^5}{120}-\frac{t^3}{2}+t^2 & \frac{t^6}{720}-\frac{t^4}{6}+\frac{t^3}{2}+\frac{t^2}{2}-t \\ 4 & \f{t} & \f{\frac{t^2}{2}} & \f{\frac{t^3}{6}} & \frac{t^4}{24}-t & \frac{t^5}{120}-t^2+t & \frac{t^6}{720}-\frac{t^3}{2}+t^2 \\ 5 & \f{t} & \f{\frac{t^2}{2}} & \f{\frac{t^3}{6}} & \f{\frac{t^4}{24}} & \frac{t^5}{120}-t & \frac{t^6}{720}-t^2+t \\ 6 & \f{t} & \f{\frac{t^2}{2}} & \f{\frac{t^3}{6}} & \f{\frac{t^4}{24}} & \f{\frac{t^5}{120}} & \frac{t^6}{720}-t \\ \end{array} $$


The number of permutations of $p$ without any run of length $r$ (or greater) is$$\int_0^\infty e^{-t}\cdot\prod_i q_{r,n_i}\!(t)\cdot\mathrm{d}t$$ where $q_{r,n}(t)$ is a polynomial in $t$ defined by $$\sum_{n=0}^\infty q_{r,n}(t)x^n=\exp\left(\frac{t(x-x^r)}{1-x^r}\right)$$
For example, $$ q_{2,1}(t)=t\\ q_{2,2}(t)=\tfrac12t^2-t\\ q_{2,3}(t)=\tfrac16t^3-t^2+t\\ q_{2,4}(t)=\tfrac1{24}t^4-\tfrac12t^3+\tfrac32t^2-t\\ q_{2,5}(t)=\tfrac1{120}t^5-\tfrac16t^4+t^3-2t^2+t$$ $$q_{3,1}(t)=t\\ q_{3,2}(t)=\tfrac12t^2\\ q_{3,3}(t)=\tfrac16t^3-t\\ q_{3,4}(t)=\tfrac1{24}t^4-t^2+t\\ q_{3,5}(t)=\tfrac1{120}t^5-\tfrac12t^3+t^2$$
To compute the integral, expand the product and use the fact that $$\int_0^\infty e^{-t}\cdot t^n\cdot\mathrm{d}t=n!$$
For an explanation of how this works, I can't think of a better introduction than Jair Taylor's paper, "Counting Words with Laguerre Series".
Edit. To make it clear: the only hard part is multiplying together the polynomials. Once they have been expanded fully, the integration is easy. Cross out the integral sign, the $e^{-t}$ and $dt$, and replace every $t^n$ with $n!$ $$\require{cancel}\cancel{\int_0^\infty e^{-t}}\cdot a\cdot t^n\cdot\cancel{\mathrm{d}t}=a\cdot n!$$
Edit 2. The coefficients of $q_{r,n}(t)$ can be derived from the $n$th row of the following table: $$\begin{array}{c|ccccc} &1&t&\tfrac1{2!}t^2&\tfrac1{3!}t^3&\ldots\\ \hline x^0&1&0&0&0&\cdots\\ x^1&0&1&0&0&\ddots\\ x^2&0&&1&0&\ddots\\ x^3&0&&&1&\ddots\\ x^4&\vdots&&&&\ddots \end{array}$$ To continue the table for a given $r$, fill the blank spaces, column by column from left to right, using the rule: $$T(n,c)=\sum_{i=0}T(n-1-ri,c-1)-T(n-r-ri,c-1)$$