4 ms·
"In this case, it's "obvious" that when e.g. a is zero, you want 1/a to be zero so you simply return b" b obviously isn't what you want from this harmonic mean
by jibal 8y ago
"In this case, it's "obvious" that when e.g. a is zero, you want 1/a to be zero so you simply return b"
b obviously isn't what you want from this harmonic mean when a is 0. And in any case x will be 2b if 1/a is 0, not b.
- semi-extrinsic 8y agoSo, I did forget the correction such that you don't get 2b. The general case is described e.g. in the link below, and this is known as a "zero-corrected harmonic mean". It is actually "obvious" in some cases, but I'll concede that in other cases it's not. https://www.rdocumentation.org/packages/lmomco/versions/2.3.1/topics/harmonic.mean https://www.rdocumentation.org/packages/lmomco/versions/2.3....
- jibal 8y agoEh? That page says nothing about 1/0 being 0, or anything like that. That function takes the harmonic mean of the non-zero samples, and then adjusts the result by multiplying it by the fraction of the samples that are non-zero. It purposefully avoids dividing by 0. And the result of that function for a==0 and b!=0 is b/2, not b or 2b. So not only is what you claim to be obvious not obvious, it's flat-out wrong.