def variance(measurements)
      return 0 if measurements.empty?

      avg = average(measurements)
      total = measurements.reduce(0) do |sum, x|
        sum + (x - avg)**2
      end
      total.to_f / measurements.size
    end
def variance(measurements)
      return 0 if measurements.empty?

      avg = average(measurements)
      total = measurements.reduce(0) do |sum, x|
        sum + (x - avg)**2
      end
      total.to_f / measurements.size
    end
Calculate variance of measurements

 @param [Array[Float]] measurements

 @return [Float]

 @api public