[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Bug in geomean()
From: |
kyfsympsn |
Subject: |
Bug in geomean() |
Date: |
Mon, 1 Oct 2012 07:36:10 -0700 (PDT) |
Hi,
Think I've noticed a big in the geomean(x) function (which can be also
written as mean(x,"g"))
In matlab, the following code:
x = rand(1000,1);
y=geomean(x)
z=exp(mean(log(x)))
...will give the same value for y and z (roughly 0.3664)
However in octave y =0!!
I think octave is probably calculating the geometric mean by multiply all
values of x (i.e. prod(x)) and then taking the nth root. Mathemaically this
is identical to exp(mean(log(x))), but programmatically prod(x) will give a
very small number and so it returns zero (or very large number if the x's
are greater than 1, hence will return Inf)
Thanks
Keith
--
View this message in context:
http://octave.1599824.n4.nabble.com/Bug-in-geomean-tp4644842.html
Sent from the Octave - General mailing list archive at Nabble.com.
- Bug in geomean(),
kyfsympsn <=