Steven Taylor wrote:
>  Could it be prettier?
>  corr=:(+/@:([...@-@(m...@[))@*@(]...@-@(m...@]))) @%:@
>  ((+/@:(*:@[...@-@(m@ [)))@*@(+/@:(*:@ (]...@-@(m...@])))))

I like the symmetry betwen  +/@:*  and  *&(+/)  in this formulation:

           correl =: (+/@:* % *&(+/)&.:*:)&(-m)

But if I were writing a real life application that required correlations, I
would use the standard definition:

           load 'stats'
           1 2 3 corr_z_ 4 5 6
        1
           corr_z_ f.
        (+/@(*~ (-"_1 _ (+/ % #))) % <:@#...@]) % *&(%:@(+/@:*:@(-"_1 _ (+/ % 
#)) %
<:@#))
           
because I trust Jsoftware has understands statistics better than I do.

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

Reply via email to