8

Assume you have a $n\times n$ matrix $M$, each entry is filled with a number from $1$ to $n^2$ randomly, and no two entries are the same.

There are $n$ rows, select the max number of each row, so there are $n$ numbers. $A$ is defined as the minimum number of these $n$ numbers. To clarify:

$$ A:= \min_{i}\max_{j} M_{ij}\\ B:= \max_{j}\min_{i} M_{ij}. $$

What is $\Pr[A>B]$?

Edit 1:

The computer run has the following result:

$$ 0.332877, 0.698953, 0.886191, 0.960409, 0.986796, 0.995996, 0.99876, 0.999604, 0.999892 $$

This is from $n=2$ to $n=10$

Edit 2:

More hint: Computer check for $\Pr[A\ge B]$ $$ 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0 $$

Code:

import numpy as np
N = 1000000
ratio = []
for n in range(2,11):
    count = 0
    for j in range(N):
        m = np.random.permutation(n**2).reshape(n,n)
        a = min([max(m[i,:]) for i in range(n)])
        b = max([min(m[:,i]) for i in range(n)])
        if(a>b):
            count += 1
    ratio.append(count/N)

print(ratio)
fizis
  • 953

1 Answers1

12

As already noted in the comments, a possible initial approach to this problem is the following. Let us suppose that, after selecting the maximal number in each row, the minimum number $A$ is that in the $j^{th} $ row. Also, let us suppose that, after selecting the minimum number in each column, the maximal number $B$ is that in the $i^{th} $ column. Now consider the number $x_{i,j} $ corresponding to the crossing point of the $i^{th} $ column and $j^{th} $ row. We directly get that $A \geq x_{i,j} \geq B $. Thus, the searched probability that $A >B $ is equal to $1-Pr[ A = x_{i,j} = B] $, where this second term expresses the probability that both the two procedures finally identify the same number in the matrix.

We can now continue as follows. First, note that the condition that both two procedures finally identify the same number in the matrix implies that there exists a number $x_{i,j} $ in the matrix which is the highest in its row, and the lowest in its column. Also note that, if such a number exists, then it must be unique. To show this, let us assume that there exists another number $x_{r,s} $ (corresponding to the crossing point of the $r^{th} $ column and $s^{th} $ row) that - just like $x_{i,j} $ - is the highest in its row, and the lowest in its column. This would imply $$x_{i,j} > x_{r,j} > x_{r,s} > x_{r,j} > x_{i,j} $$ which is clearly impossible. Therefore, we have that $Pr[ A = x_{i,j} = B]$ is equivalent to the probability that there exists a number $x_{i,j} $ in the matrix which is the highest in its row, and the lowest in its column.

We can now try to calculate this probability. The probability $P_C(k)$ that, after dividing the first $n^2$ integers in $n $ random groups of $n $ elements (i.e., the columns), a given number $k$ of this set is the lowest in its group is given by

$$P_C(k)= \frac {n^2-k}{n^2-1} \cdot \frac{n^2-k-1}{n^2-2}.... \cdot \frac {n^2-k-n+2} {n^2-n+1} $$

where the sequence of fractions expresses the probability that, given $k $, then the first, the second... and the $(n-1)^{th}$ among the other numbers in its group/column are all $>k $. This probability formula is valid only for $k \leq n^2-n+1$ (for higher values of $k $ the probability is zero). The expression above can also be written as

$$ P_C(k)= \frac {(n^2-k)!}{(n^2-k-n+1)!} \cdot \frac {(n^2-1)!}{ (n^2-n)!} =\frac {\binom{n^2-k}{n-1}} {\binom{n^2-1}{ n-1}} $$

By similar considerations, we can calculate the probability $ P_R(k) $ that, after dividing the first $n^2$ integers in other $n $ random groups of $n $ elements (i.e., the rows), our given number $k$ is the highest in its group. Because this time we have to exclude, from the possible other terms that can compare in this group, the $n-1$ terms already considered in the same column of $k $ (it is clear that these terms cannot compare also in the same row of $k $), and taking into account that all these $n-1$ terms are $>k $, we obtain

$$P_R(k) = \frac {k-1}{n^2-n} \cdot \frac{k-2}{n^2-n-1}.... \cdot \frac {k-n+1} {n^2-2n+2} $$

where again the sequence of fractions expresses the probability that, given $k $, then the first, the second... and the $(n-1)^{th}$ among the other numbers in its group/column are all $<k $. This probability formula is valid only for $k \geq n$ (for lower values of $k $ the probability is zero). Note that, for the reason explained above, the denominators have been decreased by $n-1$ as compared to those used before. The expression above can be written as

$$ P_R(k) = \frac {(k-1)!}{(k-n)!} \cdot \frac {(n^2-n)!}{ (n^2-2n+1)!} =\frac {\binom{k-1}{ n-1}} {\binom{n^2-n}{ n-1}} $$

We can now calculate the probability that in the matrix there exists a number $x_{i,j} $ that is the highest in its row and the lowest in its column. This can be obtained by summing, for all possible values of $k $, the product of $P_C(k) $ and $P_R(k)$:

$$\sum _{k=n}^{n^2-n+1} P_C(k) \cdot P_R(k) = \sum _{k=n}^{n^2-n+1} \frac {\binom{n^2-k}{ n-1}} {\binom{n^2-1}{ n-1} } \frac {\binom {k-1}{ n-1}} {\binom{n^2-n}{ n-1} } $$

Reminding that this probability is equal to $Pr[ A = x_{i,j} =B]$, we finally obtain

$$Pr[ A>B] = 1- Pr[A= x_{i,j}=B] $$

$$=1- \sum _{k=n}^{n^2-n+1} \frac {\binom{n^2-k}{ n-1}} {\binom{n^2-1}{ n-1} } \frac {\binom{k-1}{ n-1}} {\binom{n^2-n}{ n-1}} $$

Note that, for the case $n=2$, this expression reduces to the cases $k=2$ and $k=3$. Since the summation gives $1/3$ in both cases, the final result for the case $n=2$ is $$Pr [A>B]=1-1/3-1/3=1/3$$ as anticipated in the comments. The cases $n=4$ and $n=5$ give $$1-3/10=7/10$$ and $$1-4/35=31/35$$

respectively, which are very near to the experimental values reported in the OP. The probability rapidly grows up and tends to $1$. For example, for $n=10$ its value is $$1-5/46189 \approx 0.99989... $$

again confirming the experimental value.

To get a closed value, we can transform the binomial coefficients using factorials and simplify, so that the final result becomes

$$Pr [A >B] =1- \frac {2n \, (n!)^2}{(2n!)}$$

The rapid increase of the function and its first values for small $n $ are shown by WA here.

Anatoly
  • 17,079
  • 1
    You are a genius! Do you have a final formula of that, i.e. simplify the final summation to a single expression. – fizis Oct 23 '16 at 16:04
  • Hi, I have edited my answer by adding a closed form for the final formula. Maybe this closed form could also be useful to better understand why the function shows a very rapid increase. – Anatoly Oct 23 '16 at 20:02
  • 1
    But how did you arrived that closed form, can you write some critical steps? i.e. How you did the sum.. – fizis Oct 24 '16 at 02:38
  • @fizis The denominator of the sum has no $k$'s, so take it outside the sum. The remaining sum is of the form $\sum \binom{j}{b} \binom{a-j}{c}$. This is $\binom{a+1}{b+c+1}$. For a combinatorial proof, look at all ways to choose a list $L$ of $b+c+1$ elements from a set of $a+1$. Let the $(b+1)$st element of $L$ be $j+1$. Then we have chosen $b$ elements from the $j$ options before that element, and $c$ from the $a-j$ choices afterwards. Then simplify the ratio of binomial coefficients that results. But such a simple answer suggests there is a simpler proof ... – David E Speyer Oct 24 '16 at 15:29
  • @DavidSpeyer why $b+1$ and $j+1$, not just $b$ and $j$. I think $\binom{j}{b}$ means choose $b$ element from $j$ element, and $\binom{a-j}{c}$ means choose $c$ elements from $a-j$ elements. There multiply then summation should mean Choose $b+c$ elements from $a$ elements – fizis Oct 24 '16 at 15:40
  • @fizis Because once you have labeled the $(b+1)$ element of $L$ to be $j+1$, you are left with $b$ choices from $j$ for the elements of $L$ before that element. Example: Take $a=5$, $b=c=1$. The formula is $\binom{1}{1} \binom{3}{1} + \binom{2}{1} \binom{2}{1} + \binom{3}{1} \binom{1}{1} = 1 \cdot 3+2 \cdot 2 + 3 \cdot 1 = 10 = \binom{5}{3}$, which is true. This takes the $10$ three-element subsets of ${ v,w,x,y,z }$ and splits them up as ${ vwx,vwy,vwz }$ (second element is $w$), ${ vxy, wxy, vxz, wxz }$ (second element is $x$), and ${ vyz, wyz, xyz }$ (second element is $y$). – David E Speyer Oct 24 '16 at 16:01
  • @DavidSpeyer I understood, draw a picture makes it very clear. Since the $j$-th element have already be taken by choosing the $b$ elements from $1$ to $j$. If we want to choose $c$ elements from $a-j$ elements, we must start at $(j+1)$-th element till $(a+1)$-th element. – fizis Oct 24 '16 at 16:26
  • @DavidSpeyer I found my reasoning not right, there are $a-j+1$ elements from element $j+1$ to element $a+1$. – fizis Oct 25 '16 at 03:07
  • No, the element $j+1$ isn't included. Make a small example (or use mine) to check your formulas against! – David E Speyer Oct 25 '16 at 08:28
  • @Fizis: Thank you for your comments. The simplest way to get the closed form is that correctly explained by David Speyer. Considering only the numerator, it is equal to $\binom {n^2}{2n-1} $. Transforming this and the denominator in factorials and simplifying, we directly get the final closed form. – Anatoly Oct 27 '16 at 07:22