[Jprogramming] Correlation Coefficient

Henry Rich HenryHRich at nc.rr.com
Tue Jun 26 22:45:46 HKT 2007


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 % a~@[ %:@* a~@]
   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.

Henry Rich

> -----Original Message-----
> From: programming-bounces at jsoftware.com 
> [mailto:programming-bounces at jsoftware.com] On Behalf Of June Kim
> Sent: Tuesday, June 26, 2007 10:08 AM
> To: Programming forum
> Subject: [Jprogramming] Correlation Coefficient
> 
> I've been playing with the expression at
> http://en.wikipedia.org/wiki/Correlation
> 
> 
>    c=.(*&s-~#@[*s@:*)%*&(s(-~(#*s=.+/))&.:*:])
>    1 3 2 4 c 2 4 3 3.5
> 0.831522
> 
> c is as short as I can get. Could you come up with a verb for
> correlation, shorter than c?
> ----------------------------------------------------------------------
> For information about J forums see 
> http://www.jsoftware.com/forums.htm



More information about the Programming mailing list