global-methods.rb
# consumes list of numerics, produces the population standard
# deviation as a float
consumes list of numerics, produces the population standard
deviation as a float
consumes list of numerics produces the population standard deviation as a float
def standard_deviation(values)
  mu = mean(values) 
  variance = sum(values.collect {|x| (x - mu)**2 }) / (values.count)
  Math::sqrt(variance)
end
def standard_deviation ( values ) mu = mean ( values ) variance = sum ( values . collect { | x | ( x - mu ) ** 2 } ) / ( values . count ) Math :: sqrt ( variance ) end
consumes list of numerics, produces the population standard
deviation as a float
consumes list of numerics produces the population standard deviation as a float
# mean will usually have already been calculated # naive algorithm risks underflow
values
<not_specific>