Class: Array
- Inherits:
-
Object
- Object
- Array
- Defined in:
- lib/gauntlet.rb
Instance Method Summary collapse
Instance Method Details
#average ⇒ Object
315 316 317 |
# File 'lib/gauntlet.rb', line 315 def average return self.sum / self.length.to_f end |
#sample_variance ⇒ Object
319 320 321 322 323 324 |
# File 'lib/gauntlet.rb', line 319 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
326 327 328 |
# File 'lib/gauntlet.rb', line 326 def stddev return Math.sqrt(self.sample_variance) end |
#sum ⇒ Object
309 310 311 312 313 |
# File 'lib/gauntlet.rb', line 309 def sum sum = 0 self.each { |i| sum += i } sum end |