Thanks again Henry, this onaxes would be a very useful tool.
________________________________ From: Henry Rich <[email protected]> To: [email protected] Sent: Friday, May 31, 2013 9:26 PM Subject: Re: [Jprogramming] zscore in J either column wise or row wise - basic question on rank It looks to me like that's pretty close to working, except that you always want to apply v to rows, i. e. rank 1, i. e. colOrRow =. 2 : ' v"1`(v"1 &.|:)@.m' but now I must accuse you of incomplete generalization. Suppose the operand has higher rank? Isn't what you really want to apply v along a given axis? And, come to think of it, shouldn't we allow v to have any rank, and apply it to selected axes? I would switch the meanings of u and v, and write onaxes =: 2 : 'u&.(n&|:)' For rows, you would write u"1 onaxes 0 for columns, u"1 onaxes 1 You could have onaxis =: 2 : 'u"1&.(n&|:)' but I think that's a special case. Wait a minute... this means you would have to have an inverse of m&|: . What would that be? I mean, you would have to take the result, which might have any rank, and undo the transpose... how? 2&|: b. _1 (] |:~ 2 C.^:_1 i.@#@$) :.(2&|:) 3&|: b. _1 (] |:~ 3 C.^:_1 i.@#@$) :.(3&|:) I can't prove that that's right. But, knowing Roger, I bet it is. Henry Rich On 5/31/2013 8:35 PM, elton wang wrote: > thanks Henry, > to generalize the question, how do I define a conjuction colOrRow such that > for any verb v: > 0 colOrRow v is to apply v along row and combine the results row wise, while > 1 colOrRow v is to apply v along column and combine the results column wise? > > I tried colOrRow =. 2 : ' v`(v"1 &.|:)@.m'. but this is not working. > > > > > ________________________________ > From: Henry Rich <[email protected]> > To: [email protected] > Sent: Friday, May 31, 2013 8:16 PM > Subject: Re: [Jprogramming] zscore in J either column wise or row wise - > basic question on rank > > > A good testcase for the new dissect tool! > > > load '~addons/debug/dissect/dissect.ijs' > > z0 =. (- mean) % stddev > z0 i. 3 4 > |length error: z0 > | z0 i.3 4 > > what's it doing in there? > z0 f. > (- (+/ % #)) % %:@(+/@:*:@(-"_1 _ (+/ % #)) % <:@#) > > run dissect on that: > > ds '((- (+/ % #)) % %:@(+/@:*:@(-"_1 _ (+/ % #)) % <:@#)) i. 3 4' > > the display shows that there is agreement error in (- mean). Oh yeah, > to work at high rank, you have to put the correct rank on - and % : > > z0 =. (-"_1 _ mean) %"_1 _ stddev > z0 i. 3 4 > _1 _1 _1 _1 > 0 0 0 0 > 1 1 1 1 > z0"1 i. 3 4 > _1.1619 _0.387298 0.387298 1.1619 > _1.1619 _0.387298 0.387298 1.1619 > _1.1619 _0.387298 0.387298 1.1619 > > I don't know if that's correct, but the ranks are right. > > Henry Rich > > On 5/31/2013 7:57 PM, elton wang wrote: >> if I define zscore as z0 =. (- mean) % stddev, z0 works for rank 1 array. >> For a rank 2 array like a=. i. 3 4, if I want to get zscore along either >> column or row, I could define >> z1 =. [: |: stddev %~ |: - mean >> >> >> z1 i. 3 3 >> _1 _1 _1 >> 0 0 0 >> 1 1 1 >> >> and >> >> z1"1 i. 3 3 >> _1 0 1 >> _1 0 1 >> _1 0 1 >> >> My question is that z1 uses |: twice and looks awkward. If there any clever >> way to implement z1 by rank annotation or something? >> ---------------------------------------------------------------------- >> 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 > ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm
