I now finally have a real-life example and ran into the problem that Leo
was talking about.
Unfortunately, it is too big to post here, but I've placed the input
file at: http://www.hometot.com/images/jtable.ijs (97154 bytes).
Running the code, I get 2 rows (out of 93) and 1034 columns (out of
1042) as the answer.
OK, so now I'm trying to limit the result to a maximum of 64 columns.
I've tried a number of different approaches... first, generating a
temporary result in 'z' using this:
z=:(-.=i.#table)*.(+/ . *. |:) table
Now, this gives me the counts of the number of times each row matches
another row, and in which column.
If I clamp this table such that the maximum value is 64, like so:
f =: 4 : 0
y =. ,y
(y>x)#(i.#y)
)
64 f } z
then I get really weird results when I tried that, so I figured I messed
up the relationships.
So I finally tried only using the values that equaled 64:
]j=: i,I.s{~ i=.(i.>./)+/ s=.(z = 64)
52 1 23 36 78
]k=: I.*./ j{table
7 46 147 165 251 329 365 374 487 540 562 630 656 663 790 842 850 859 869
883 955 994 1030
$ k
23
I'm surprised that $k wasn't equal to 64. And I'm still a bit confused
as to why we start j off with i.
Can anyone see what I'm doing wrong?
Thanks!
-- Glenn
Leo Vo~handu wrote:
Nice. But I would like to ask Glenn- how does he define the best result?
F.e for data table
1 1 1 0 1 1 1
1 1 1 0 0 0 0
1 1 1 0 0 0 0
0 0 0 1 1 1 1
Longest row (0), 3*3 clique 012 or even rows 1,2 as most alike?
Glenn mention his algorithmic result somewhere, how is the "best" defined?
Leo
It testifies to importance of good test data,
as provided in a separate message by Glenn.
Another correction--now obvious.
]r=: "."0;._2'101010101 100100100 100010001 000010000 010011100 '
1 0 1 0 1 0 1 0 1
1 0 0 1 0 0 1 0 0
1 0 0 0 1 0 0 0 1
0 0 0 0 1 0 0 0 0
0 1 0 0 1 1 1 0 0
]j=. i,I.s{~ i=.(i.>./)+/ s=.(= >./@,) (-.=i.#r)*.(+/ . *. |:) r
0 2
]k=. I.*./ j{r
0 4 8
Note (f/ . g |:) is the same as f/@:g"1/~
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm