[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: geometric mean?



In article <39B8B345.FDF4E45D@dkrz.de>,
  Martin Schultz <martin.schultz@dkrz.de> wrote:
> Hi Andrew,
>
>    I couldn't find such a routine either so I decided to hack it
> together using the algorithm you suggest but including some error
> cehcking and more caution with range limits or negative values. You
> can find geomean.pro on my web pages:
>
http://www.mpimet.mpg.de/~schultz.martin/idl/html/libmartin_schultz.html
>
> Cheers,
> Martin
>

Dear Martin,

   Thanks!!!

   You include checking for negative values, which would mess
up the ALOG function.

   Since I am taking geometric means of rates that are by
definition positive, I did not think of negative numbers.

   There is a problem, though...

   Someone please correct me if this is wrong; I'm not 100% sure.
The way I implemented the geometric mean was not the DEFINITION of
the geomean, but rather a computational SHORTCUT.

    The DEFINITION goes something like:

    GEOMEAN(Arr)=(PROD(Arr))^(1/n), where n is the number of elements,
and PROD is the product operator.  Logging both sides gets rid of the
nasty "nth root" (i.e. ^(1/n)) and turns the product into a sum, which
is also nice.  Then exponentiating un-transforms the log.

    Clearly we can't log any negative number, but we can product a
bunch of numbers and then take an nth root of the result.  And if there
are zero or an even number of negative numbers there will be a real
nth root, hence (I guess), the geomean would exist.

    I don't know what the convention is with negative numbers, and
it doesn't affect me because I am using positive numbers, but maybe
someone out there knows:

   (1)  Is geomean by convention undefined if any numbers in the set
        are negative?

   (2)  Is geomean always the positive nth root?  geomean of -2 and -2
        is +2?


   Cheers,
          Andrew



Sent via Deja.com http://www.deja.com/
Before you buy.