Created
January 5, 2011 21:57
-
-
Save FestivalBobcats/767098 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def self.volatility(prices) | |
mean = (prices.inject {|s,n| s+n}) / prices.length | |
sd = Math.sqrt((prices.inject(0) {|s,n| s + (n-mean)*(n-mean)}) / (prices.length-1)) | |
rsd = sd/mean*100 | |
('%.2f'%rsd) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment