3

I have two decimal number variables, colSum and rowSum, using those I want to build a matrix of binary values based on those sums, the rowSum array variable is the result of adding all the 1's for each row, the same goes for colSum array.

So ,if you have

rowSum = [0,1,2]
colSum = [1,1,1]

you will have to build properly the following array

matrix = [
 [0,0,0],
 [0,0,1],
 [1,1,0]
]

I'm using this method in PHP, that works for a 3x3 matrix, but not for a bigger one, like 8x8. First ,fill all the 1's in the rows using the rowSum value. Then ,try to find a wrong sum value of 2 columns, with a pivot I inter-change them (1 with a cero value) in the same row, until i get the correct value of colSum. But it will not work because I need some control of the criteria to change the 1 and 0 in the same row for two columns...

This is the method I'm using.

Let's say we have this Matrix (N=3 -> NxN):

0  0  0
0  0  1
1  1  0

then we have the following arrays

R0 = {0,1,2} //--> result of sums of each rows: ( 0+0+0, 0+0+1 , 1+1+0 )
C0 = {1,1,1} // ->sums of each columns

Step 1

Create and fill a NxN array using as many 1's as R0(i) in each row:

0  0  0
1  0  0
1  1  0 

compute sums of this new matrix now: R1 = {0,1,2} C1 = {2,1,0}

Step 2

Check if for all the elements of the column sums of the created matrix has the same value as C0 (origin)

for ( i=0, N-1) do

 if C0(i)!=C1(i) then
   ReplaceColumn(i)
 end

end

To replace a column we have to dig inside the conditions. C0(0) = 1 != C1(0) = 2 the first column sum does meet the condition to call the replace ,so

Step 3

Choose criteria for apply the branch & bound method and find the best row to change column that satisfy the global condition (all column sums).

The amount of changes for a difference between columns sums is:

|C0(i)-C1(i)| 

for this example, |C0(0)-C1(0)| = 1 change. Go back condition must be if the change generates a greater difference between the total sum of columns.

Σi,N(|C0(i)-C1(i)|)

So, could this method really work?

juaxix
  • 63
  • 7
  • 2
    In the general case, there are multiple solutions. I just happen to have read [a nice little paper ('A Combinatorial Interpretation...' Chad Brewbaker)](http://www.kurims.kyoto-u.ac.jp/EMIS/journals/INTEGERS/papers/i2/i2.pdf) describing how many lonesum cases there are. – dwn Jan 15 '15 at 18:36
  • Very interesting, I think that this Theorem 1 (Ryser 1957[14]) could really works for interchanges... – juaxix Jan 15 '15 at 18:53
  • I also found these readings interesting http://www.ces.clemson.edu/~janoski/thesis.pdf and http://conf.uni-obuda.hu/cinti2008/26_cinti2008_submission.pdf the last one using branch and bound, like i suppose. But I think you need more than the cols and rows sums to build the matrix, maybe this attaching ones together thing could work :) – juaxix Jan 18 '15 at 23:27
  • I've had an idea in mind for a few years related to this kind of thing. Do you mind if I ask what piqued your interest in this subject? – dwn Jan 18 '15 at 23:56
  • Yes @dwn ,it is a feeling like in that movie "Proof", i feel in my head a tingle in my brain with math and programming and, this kind of things could help to our deep understanding of both (matrix in this case) and contribute to a higher cause, whats yours? – juaxix Jan 20 '15 at 02:41
  • I noticed that the generating functions for multi-poly-Bernoulli numbers could be given straightforward Bayesian interpretations. The connection between reconstructable matrix memories and Bayesian inference seemed interesting. I tried to write a paper about it, but came to a point where it seemed 1+1 no longer equaled 2, so to speak. I'll have to see if I can find it sometime. – dwn Jan 20 '15 at 04:21
  • I see your point, i think the same when i use a method to build the matrix that could seems to be ok but then it is not xD – juaxix Jan 20 '15 at 09:57
  • Yeah, sucks, doesn't it. I know the basic math was sound, but am afraid to disinter it, might unleash a black plasma ocean on my life. – dwn Jan 20 '15 at 14:00

1 Answers1

1

Is the goal to construct the matrix that satisfies the row and column sums or a matrix that satisfies them? It's not clear from the question, but if it's the former ("the" case) then it's not going to possible.

Suppose it were the case that you could uniquely represent any m × m matrix of bits in this way. Then consider the following hypothetical compression algorithm.

  • Take 22n bits of data
  • Treat it as 2n × 2n bits
  • To describe the data, use 2 × 2n row and column sums, each using at most log2(2n) = n bits
  • The data is compressed to 2 × n × 2n bits

Since 2 × n × 2n << 22n and this process could just keep being repeated, the supposition that you can uniquely represent any m × m matrix of bits by only its row and column sums is false.

Timothy Shields
  • 75,459
  • 18
  • 120
  • 173
  • Thanks for the theory,Timothy, we know now that the matrix can't be rebuild only with cols and row, ...now, can you do some trick like the paper http://conf.uni-obuda.hu/cinti2008/26_cinti2008_submission.pdf or use diagonals sums? – juaxix Jan 22 '15 at 00:05