I have several records with a given attribute, and I want to find the standard deviation.
How do I do that?
Or how about:
class Stats def initialize( a ) @avg = a.count > 0 ? a.sum / a.count.to_f : 0.0 @stdev = a.count > 0 ? ( a.reduce(0){ |sum, v| sum + (@avg - v) ** 2 } / a.count ) ** 0.5 : 0.0 end end