class MoreMath::Sequence
def harmonic_mean
Returns the harmonic mean of the elements. If any of the elements
def harmonic_mean sum = @elements.inject(0.0) { |s, t| if t > 0 s + 1.0 / t else break nil end } sum ? size / sum : 0 / 0.0 end
def harmonic_mean sum = @elements.inject(0.0) { |s, t| if t > 0 s + 1.0 / t else break nil end } sum ? size / sum : 0 / 0.0 end