[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
## [patch #8052] Harmonic means for descriptive statistics

**From**: |
John Darrington |

**Subject**: |
[patch #8052] Harmonic means for descriptive statistics |

**Date**: |
Sat, 25 May 2013 05:33:36 +0000 |

**User-agent**: |
Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20100101 Firefox/10.0.12 Iceweasel/10.0.12 |

Follow-up Comment #2, patch #8052 (project pspp):
+ /* Sum of reciprocals only needed for variables with only positive
values */
+ m->sumreci = (value <= 0. || m->sumreci == SYSMIS) ? SYSMIS :
m->sumreci + 1 / value * weight;
I don't understand why there is this exception for values less than or equal
to zero.
The harmonic mean is well defined for negative values, so we don't need to
make a special case there. Where a value is exactly equal to zero, the
reciprocal of course is infinite. However since we are dealing with floating
point numbers, this will be recognised by the floating point library and the
end result will be (correctly) NaN. So as far as I can see, we don't need to
special case zero either.
_______________________________________________________
Reply to this item at:
<http://savannah.gnu.org/patch/?8052>
_______________________________________________
Message sent via/by Savannah
http://savannah.gnu.org/