Re: GEOMETRIC mean computation: TEST of proposed tecniques for
- From: pamela fluente <pamelafluente@xxxxxxxxx>
- Date: Sat, 21 Jul 2007 02:48:00 -0700
On 21 Lug, 11:33, Raymond Manzoni <raym...@xxxxxxx> wrote:
David Bernier a écrit :
pamela fluente wrote:
Continuing from:
http://groups.google.it/group/sci.math/browse_thread/thread/c2307b8fe...
I don't see my posts (?). Perhaps Google is holding them.
I will try starting a new thread with some tests on your algorithm.
Google can be late in adding messages to Google Groups archives.
I post through a news-server in Canada, and it is independent
completely from Google Groups.
I recommend the product of 20 terms then log(.) of Raymond Manzoni.
It would be faster than my idea. Also, it would be quite helpful
for those who know about computing geometric means efficiently
if
----> you can give constants C>0 and D>0 such that
----> C < | a(n)* a(n+1)* .... a(n+19)| < D
----> *always* for your data...
In the spirit of Raymond Manzoni's idea, it is very important
that multiplying 20 consecutive terms does *not* cause
Overflow or Underflow....
Only you can tell people of sci.math the maximum D and the
minimum C. Also, do you use floating point numbers? If so,
are they 32-bit, 64-bit or something else?
You see, without C and D, we can't say if there is a
possibility of Overflow or Underflow when multiplying
20 terms (both Overflow and Underflow are bad).
Regards,
David Bernier
Hi David,
In fact if your language allows exception handling you may write code
without this knowledge (merely supposing that unapropriate data will be
uncommon!) :
- in a global way (in C++ for example) :
try
//fast complete (say) 32 terms code
except (...)
{
//slower and more cautious code
}
- in a local way (catching failure in one of the sum term only) :
#define MAX 31
while (s+MAX <= sMax)
{
try
r = log(s[0]*...*s[MAX]); //or log(fabs(...))
except (...)
{
//something more cautious log(0) not wished!!!
r= 0;
for (int i=0; i<=MAX; i++)
if (s[i] != 0.0)
r += log(fabs(s[i]));
}
sum += r;
s += MAX;
}
The exception catching method may be of use too for the other methods
proposed....
Best regards!
Raymond- Nascondi testo tra virgolette -
- Mostra testo tra virgolette -
Yes Raymond. I also thought about that.
Instead of checking that the mean is greater that an upport threshold
of below a lower one, using a try catch on overflow.
However, I think this would slow down terribly the method because then
you would need several
operation to reduce your mean within reasonable bounds, and this slows
down.
If you dont, you remain "close" to the error condition, you are going
to get lots of exceptions
and this is also quite slowing down.
So probably we need a careful choice of the 2 threshold and the
reduction factor (2, 1000, or whatever) .
-P
.
- References:
- GEOMETRIC mean computation: TEST of proposed tecniques for
- From: pamela fluente
- Re: GEOMETRIC mean computation: TEST of proposed tecniques for
- From: David Bernier
- Re: GEOMETRIC mean computation: TEST of proposed tecniques for
- From: Raymond Manzoni
- GEOMETRIC mean computation: TEST of proposed tecniques for
- Prev by Date: Re: GEOMETRIC mean computation: TEST of proposed tecniques for
- Next by Date: (2^p) - 1 = prime numbers
- Previous by thread: Re: GEOMETRIC mean computation: TEST of proposed tecniques for
- Next by thread: Question about polygons
- Index(es):
Relevant Pages
|