1

We arrange $N$ boys and $M$ girls in a row with importance of order (thus, we have $(N+M)!$ permutations for that arrangement). In how many ways can we get a maximal sequence of $K$ boys OR $K$ girls (or both)?

For example, here we have an arrangement of $N=4$ boys and $M=5$ girls with a maximal sequence of $K=3$ :

$$GGBGGBBBG$$ Of course we could have a sequence of 3 girls AND 3 boys in other row, that counts too.

EDIT: People told me that my interpretation for "maximal sequence" wasn't clear enough, so let me be more precise: I am looking for the Probability that there is at least one sequence of $K$ boys OR $K$ girls OR both - AND no sequence bigger than K. $$$$

I tried everything but (apparently) I always get duplications in my counting. I coded a python code which calculates exactly that, just for testing, and none of my trials worked (my answers was always bigger).

I'd really appreciate your help!

My attempt was: $\frac{{N\choose K}(N+M-K+1)!K!+{M\choose K}(N+M-K+1)!K!}{(N+M)!}$

where ${N\choose K}$ for choosing $K$ boys, $(N+M-K+1)!$ for putting everyone in line while relating the $K$ chosen-boys as one, then $K!$ for all of their permutations(the K-chosen-boys). Same thing for the girls. Devide all that with $(N+M)!$.

ryden
  • 583
  • Can you show your work? It should be straightforward for $M = 4, N = 5, K = 3$. – Math Lover Jan 04 '22 at 06:36
  • That's the output for your values:

    $$$$ We have 5 boys and 4 girls. There are $233280$ possibilities out of $362880$. $P(k=3) = 0.6428571428571429$

    – ryden Jan 04 '22 at 09:52
  • 1
    I do not understand your comment. Is that an output from a program? That answer seems incorrect. Can you please edit the question to show your attempt to solve and not the program output? – Math Lover Jan 04 '22 at 10:13
  • How are you attempting? You have not shared any details of that. Why don't you edit to show your approach and work? Otherwise this question will likely get closed. Also I will check and confirm but at the outset, the output of the program seems wrong to me. – Math Lover Jan 04 '22 at 12:45
  • I added my attempt, which is wrong according to my program. I believe my calculation contains some duplications, but i can't see how to get rid of them.. – ryden Jan 04 '22 at 12:58
  • Yes I see and it does contain duplicates. One of the ways would be to apply Principle of Inclusion Exclusion but it will not be a closed form for $N, M, K$. You can see the approach for $M = 4, N = 5, K = 3$ – Math Lover Jan 04 '22 at 13:02
  • I'm not sure how.. I'm afraid it's too difficult for me :\
    Please, can you show me what was your solution using the Principle of Inclusion Exclusion?
    – ryden Jan 04 '22 at 14:39

1 Answers1

1

In this answer it is calculated that the bivariate generating function for the binary words that contain runs (of either symbol) of length at most $k$ is

$$G_k(u,w) = \frac{\frac{1-u^{k+1}}{1-u} \frac{1-w^{k+1}}{1-w}}{1 - u\frac{1-u^{k}}{1-u}w\frac{1-w^{k}}{1-w}}. $$

Notice that now $G_k(u,w)-G_{k-1}(u,w)$ enumerates the words with maximal run equal to $k$ i.e. we subtract the number of words where the maximal run is at most $k-1$.

I include here a SageMath script that does calculation

def f(n,m,k):
    R.<u,w> = PowerSeriesRing(QQ, 2)
    prec = n+m+1 #upto what order we need
    H = lambda z, kk: (1-z^kk)/(1-z).O(prec) #helper
    G = H(u,k+1) * H(w,k+1) / (1-u*H(u,k)*w*H(w,k)).O(prec) - H(u,k) * H(w,k) / (1-u*H(u,k-1)*w*H(w,k-1)).O(prec)
    return G.coefficients()[u^n*w^m]

print (f(5,4,3))

This gives the answer as the number of binary words. If you want the order among the boys and among the girls to matter as you do, multiply the answer by $m!n!$.

ploosu2
  • 8,707