Monday, March 19, 2012

Harmonic Mean

Hello everyone.
My first time posting here! I have recentl been computing the geometric mean of a column in out Swl Server 200 Db using the following script:
@.PE_Geo = exp(avg(log(PE1)))

this has worked greate, however I need to change this to the harmonic mean. Anyone have any ideas on the cimplest way to do this.

A simple example of the harmonic mean:
If you want the harmonic mean of 10 and 20, you first
take 1/10 and 1/20, find their average, which is 3/40, and then take
the reciprocal of that, 40/3.

In algebra, the harmonic mean h of two numbers a and b is

1 / ( (1/a + 1/b) / 2),

or in other words

1/m = 1/2 (1/a + 1/b).

Thanks for any help!select 1/(sum(1/[value])/count([value]))

You made need to cast your value as a different datatype to prevent rounding errors.

blindman|||Originally posted by blindman
select 1/(sum(1/[value])/count([value]))

You made need to cast your value as a different datatype to prevent rounding errors.

blindman

Thank you!
Float ok?|||Depends on your data. Float and Real are approximate values, and I don't know how they might propogate errors. Numeric and Decimal are more accurate, but you must define their accuracy ahead of time.

blindman|||Thanks again...
BTW: Have an experts-exchange account: 100pts!

http://www.experts-exchange.com/Databases/Q_20704165.html|||I've thought about joining Experts Exchange, but what would I do with the 100 points? Can I trade them in for a toaster?

blindman|||Hehe...

No comments:

Post a Comment