# Matrix + combinatorial or conditional probability: bit patterns

I'm trying to get my head around a problem, and it's not working.

The problem: consider an NxN matrix that represents a binary number. For instance, a 4x4 matrix is a 16 bit number, a 6x6 matrix is a 36 bit number. N will always be even.

Now, for any given N, how many matrices / numbers are there where every row and column has exactly half of its values 0 and half 1?

Here is what I have learned so far:

• From brute force, I know that the answer for a 2x2 matrix is 2. For a 4x4 matrix, the answer is 90.
• I can calculate the number of rows OR columns that half half of their bits on with the formula: $$f(n) = {n! \over (n/2)!^2} * 2 ^ {n^2}$$
• But I can't simply take percentage of rows times percentage of columns, presumably because they are not independent.

The sequence, incidentally, begins $1, 2, 90, 297200, 116963796250, 6736218287430460752,\ldots$