From: "Älphä Blüë" Date: 2009-07-22T08:21:33+09:00 Subject: Re: Standard Deviation question regarding EDOM errors Hi David, Thanks for showing me my error. So, I implemented a change in the class for testing purposes: class Stdev def initialize(arr) @arr = arr @size = @arr.to_a.size end def sum @arr.inject {|a,b| a + b } end def product total = 0.0 @arr.each {|a| total += a * a } total end def calculate Math.sqrt(((product - (sum * sum)/@size)/(@size-1))) end end Running the same test with the same things: a = [1,2,3,4,5] b = [1,2] c = [123.369, 68.6179] stddev(a) => 1.58113883008419 (correct) stddev(b) => 1.0 (NOT expected) stddev(c) => 38.7148740874228 (correct) So, compared to the class now, versus the method I created, do you see any anomolies that would change this behavior? -- Posted via http://www.ruby-forum.com/.