Get mean value
def mean(x) sum=0 x.each {|v| sum += v} sum/x.size end data = [1.1,2.3,3.3,1.2,4.5,2.1,6.6 ] puts am = mean(data) # 3.014285714