def covariance(xs, ys)
      raise "Length xs and ys must be equal" unless xs.length == ys.length

      xys = xs.zip(ys).map{|x,y| x * y }
      mean(xys) - mean(xs) * mean(ys)
    end
def covariance(xs, ys)
      raise "Length xs and ys must be equal" unless xs.length == ys.length

      xys = xs.zip(ys).map{|x,y| x * y }
      mean(xys) - mean(xs) * mean(ys)
    end
Covariance
 http://en.wikipedia.org/wiki/Covariance