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