--- Henry Rich <[EMAIL PROTECTED]> wrote:

> Not really, but gee, shouldn't we be using our wonderful
> language to provide the most expressive form of c rather
> than just the shortest?
> 
>    a =. (# * +/)@:* - *&(+/)
>    c =. a % [EMAIL PROTECTED] %:@* [EMAIL PROTECTED]
>    1 3 2 4 c 2 4 3 3.5
> 0.831522
> 
>    a =. ((# * +/)@:* - *&(+/)) "1
>    c =. %: @ (%~/ . *) @: (a/~) @: ,: 
>    1 3 2 4 c 2 4 3 3.5
> 0.831522
> 
> I don't think either of these forms is useful for real work,
> since they involve subtracting big near-equal numbers, but
> I learned something about the computation by writing them.

That is easily seen running the Wikipedia stability test
http://en.wikipedia.org/wiki/Correlation#Computing_correlation_accurately_in_a_single_pass

   CR=: (+/@:* % *&(+/)&.:*:)&(- +/ % #)

   0j20":CR/900000000(+,:-)1+i.1000000
_1.00000000000000000000

   COR f.
(+/ % #)@:*&(- (+/ % #)) % *&(%:@(+/ % #)@:*:@:- (+/ % #))

   0j20":COR/900000000(+,:-)1+i.1000000
_1.00000000000000000000

   0j20":c/900000000(+,:-)1+i.1000000
1.00000229430253350000

   load'stats'
   0j20":corr/900000000(+,:-)1+i.1000000
_0.99999999999619615000



       
____________________________________________________________________________________
Got a little couch potato? 
Check out fun summer activities for kids.
http://search.yahoo.com/search?fr=oni_on_mail&p=summer+activities+for+kids&cs=bz
 
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to