class MoreMath::Sequence

def geometric_mean

elements is less than 0.0, this method returns NaN.
Returns the geometric mean of the elements. If any of the
def geometric_mean
  @geometric_mean ||= (
    sum = @elements.inject(0.0) { |s, t|
      case
      when t > 0
        s + Math.log(t)
      when t == 0
        break :null
      else
        break nil
      end
    }
    case sum
    when :null
      0.0
    when Float
      Math.exp(sum / size)
    else
      0 / 0.0
    end
  )
end