Skip to content

Instantly share code, notes, and snippets.

View mfdela's full-sized avatar

Marco Delaurenti mfdela

View GitHub Profile
@mfdela
mfdela / pearson.rb
Created February 13, 2011 00:37
Pearson produt-moment correlation coefficient
#!/usr/bin/ruby
class Array
def sum
inject( 0 ) { |sum,x| sum+x }
end
def sum_square
inject( 0 ) { |sum,x| sum+x*x }
end
def mean