Hi all -

Sharing something I observed ...

While the definitions (for arithmetic and geometric mean)

   amean=: +/ % #
and
   gmean=: */ %:~ #

are nice to look at as a pair (because of symmetry) I prefer this definition of geometric mean

   gmean=: [: */ # %: ]
or
   NB. using the Log domain
   gmean=: [: ^ [: amean ^.

because, given these (intermediate) definitions

   NB. often found
   gm0=. */ %:~ #
   NB. taking the roots first, then multiply
   gm1=. [: */ # %: ]
   NB. definition found on (&.:) page of NuVoc
   gm2=. amean &.: ^.

I got these results (see gm0 failing while the other two hold)

   (gm0,gm1,gm2) >: ? 6 $~ 637
3.04409 3.04409 3.04409
   (gm0,gm1,gm2) >: ? 6 $~ 638
_ 3.05264 3.05264
   (gm0,gm1,gm2) >: ? 6 $~ 2^24
_ 2.99357 2.99357

under J v8.04 on a 32-bit Vista machine.

Thanks
-M

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

Reply via email to