Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/gauntlet.rb
Instance Method Summary collapse
Instance Method Details
#average ⇒ Object
321 322 323 |
# File 'lib/gauntlet.rb', line 321 def average return self.sum / self.length.to_f end |
#sample_variance ⇒ Object
325 326 327 328 329 330 |
# File 'lib/gauntlet.rb', line 325 def sample_variance avg = self.average sum = 0 self.each { |i| sum += (i - avg) ** 2 } return (1 / self.length.to_f * sum) end |
#stddev ⇒ Object
332 333 334 |
# File 'lib/gauntlet.rb', line 332 def stddev return Math.sqrt(self.sample_variance) end |
#sum ⇒ Object
315 316 317 318 319 |
# File 'lib/gauntlet.rb', line 315 def sum sum = 0 self.each { |i| sum += i } sum end |