'69 Camaro said:
Hi, Smartin.
Agreed. Unfortunately, many folks use the newsgroups for copy/pasting code,
but if there is any error in the code they have no way of knowing unless they
have the math and programming skills themselves. It's a catch-22, since if
they had the skills, they wouldn't have copy/pasted someone else's code.
It's a good starting point, but folks may not realize it's only the starting
point, and use it as is. That's why I wanted you to look at your code with a
more critical eye, which you did.
There's more than one formula for harmonic mean. None of the values can be
zero, because the values are used in the denominator of the equation.
However, most common uses of harmonic mean require only positive real numbers
in the data set. Consider what the result would be if there were any
negative real numbers in the data set.
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
http://www.Access.QBuilt.com/html/expert_contributors2.html for contact info.
Your points are well taken, Gunny. Presumably, the OP has a good grasp of what
She or He needs in terms of the data, but is on the steeper part of the
learning curve of coding knowledge. I did include a couple disclaimers to
discourage untested use (i.e., "kludge", "[no] error checking") but perhaps I
am being too technical.
I reckon I tend to operate on the premise that most readers are like myself:
inquisitive, a bit adventuresome, and willing to try something even if it
looks like gibberish in the hopes that it magically works. When things work
out we can study the example to figure out the /how/ and improve our
understanding. I learn well through examples such as this, and hope in turn my
examples can serve others in the same capacity.
I certainly don't claim to be a pro though! I don't want to offer any bad or
misleading information, so I do appreciate constructive criticism, including
yours.
Now about this:
Consider what the result would be if there were
any negative real numbers in the data set.
Interesting... I regard the site I was referring to as an excellent source of
mathematical information yet it mentions nothing about the domain of the
members of the set. An innocent omission perhaps? Clearly zero is invalid
since we are adding reciprocals, but if we have, say, R and -R as our set,
then we will get:
1/H = 1/2 * (1/R + 1/-R)
1/H = 1/2 * 0
1/H = 0
uh oh...
I am hoping the OP knows of these pitfalls!
Thanks again,