Results 1 to 7 of 7

Thread: Harmonic Mean

  1. #1
    Join Date
    Jun 2003
    Location
    New York
    Posts
    5

    Talking Unanswered: 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!

  2. #2
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    select 1/(sum(1/[value])/count([value]))

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

    blindman

  3. #3
    Join Date
    Jun 2003
    Location
    New York
    Posts
    5
    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?

  4. #4
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    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

  5. #5
    Join Date
    Jun 2003
    Location
    New York
    Posts
    5
    Thanks again...
    BTW: Have an experts-exchange account: 100pts!

    http://www.experts-exchange.com/Data..._20704165.html

  6. #6
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    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

  7. #7
    Join Date
    Jun 2003
    Location
    New York
    Posts
    5
    Hehe...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •