def mean(x)
  sum=0
  x.each {|v| sum += v}
  sum/x.size
end

def hmean(x)
  sum=0
  x.each {|v| sum += (1.0/v)}
  x.size/sum
end

def gmean(x)
  prod=1.0
  x.each {|v| prod *= v}
  prod**(1.0/x.size)
end

data = [1.1, 2.3, 3.3, 1.2, 4.5, 2.1, 6.6]
am = mean(data)   # 3.014285714
hm = hmean(data)  # 2.101997946
gm = gmean(data)  # 2.508411474

