That's an excellent question. I'm not sure I've figured it out yet myself.
What would really be nice is if the result came as a sorted list of
most-columns to least-columns... and then you could choose which one is
optimal for the particular situation.
For your example, they would be ordered like this:
0 (6 columns, but only 1 row)
3 (4 columns, but again only 1 row)
0 1 2 (3 columns, 3 rows)
0 3 (3 columns, 2 rows)
Since my goal is to have as many columns as possible, but more than one
row, I would probably choose the 0 1 2 case for this example.
But having all the combinations sure would be it easier to choose.
Thanks, Leo!
-- 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/~
--- "Glenn M. Lewis" <[EMAIL PROTECTED]> wrote:
Sorry for replying to my own post again, but after a nice shower
(where I do my best thinking), I think I have almost figured out what
Oleg wrote...
First, he compares each row of the table with each other row with the
following expression:
="1/~ t
Next, he sums up the resulting planes into a single table:
+/@:="1/~ t
He then takes the identity matrix (using the size of the original
table... which makes me wonder if this solution will work for a
non-square table) and inverts it:
(-.=i.1{$t)
He multiplies this with the sums above to remove the main diagonal
(which represents each row matching itself):
(-.=i.1{$t)*.+/@:="1/~ t
This now contains the number of times that each row matches other rows
for each column. Then he marks the maximums in this table with ones
and everything else with zeros:
(= >./@,)(-.=i.1{$t)*.+/@:="1/~ t
Now, things start to get a little fuzzy for me...
This would sum the rows:
+/s
And this would perform the logical and of the columns:
>./s
But the expression (i.>./s) seems to generate the empty list, and i
turns out to be zero.
So I think I'm lost. Can anyone please shed some more light on this
one for me?
Thanks!
-- Glenn
Glenn M. Lewis wrote:
Wow!!! That is very impressive! I tried pulling apart the line (by
executing tiny bits at a time and displaying the line in boxed
format), and I still don't fully understand it yet, but I was able
to tweak it slightly to get it to produce a result... Here's my
minor tweak:
t
1 0 1 1 1 1 1 0
0 1 1 1 1 0 1 1
1 1 1 1 0 1 1 0
1 1 1 1 0 1 1 1
1 1 0 0 1 1 1 1
1 0 1 1 1 1 1 1
1 1 1 1 1 1 1 0
0 1 0 1 1 0 1 1
]j=. i,I.s{~i=.(i.>./)@:(+/) s=.(= >./@,)(-.=i.1{$t)*.+/@:="1/~t
0 5 6
]k=. I.*./ j{t
0 2 3 4 5 6
Thanks a bunch, Oleg! Hopefully before my next birthday I will have
figured out what you just wrote. :-)
-- Glenn
____________________________________________________________________________________
Bored stiff? Loosen up...
Download and play hundreds of games for free on Yahoo! Games.
http://games.yahoo.com/games/front
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm