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

Reply via email to