Hi,

is this what you mean:

a=: 6 4 $1 0 0 1 1 1 0 1 1 1 0 1 1 1 0 1 0 1 1 1 0 0 0 0
b=:1 2 1 3 4 6

(+/%+/@:*) a*b

Esa
-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of pascha
Sent: 25. syyskuuta 2012 18:16
To: [email protected]
Subject: [Jprogramming] array operation and take average


I spent a lot of time on this but I can't figure out how to do that:
I have:
"a" (6 x 4):
1 0 0 1
1 1 0 1
1 1 0 1
1 1 0 1
0 1 1 1
0 0 0 0

and "b" (1 x 6) like:
1 2 1 3 4 6

I'd like to get the average of those in "b" w.r.t column values in "a" which
are equal to 1.
At the end I'd get the averages (4 x 1 or 1 x 4), like:
(1 + 2 + 1 + 3) % 4
(2 + 1 + 3 + 4) % 4
(4)
(1 + 2 + 1 + 3 + 4) % 5

could you shed some light on this?
-- 
View this message in context: 
http://old.nabble.com/array-operation-and-take-average-tp34477891s24193p34477891.html
Sent from the J Programming mailing list archive at Nabble.com.

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to