Module: Enumerable
- Defined in:
- lib/charles.rb
Instance Method Summary collapse
Instance Method Details
#mean ⇒ Object
52 53 54 |
# File 'lib/charles.rb', line 52 def mean return self.sum / self.length.to_f end |
#sample_variance ⇒ Object
56 57 58 59 60 |
# File 'lib/charles.rb', line 56 def sample_variance m = self.mean sum = self.inject(0){|accum, i| accum + (i - m) ** 2 } return sum / (self.length - 1).to_f end |
#standard_deviation ⇒ Object
62 63 64 |
# File 'lib/charles.rb', line 62 def standard_deviation return Math.sqrt(self.sample_variance) end |
#sum ⇒ Object
48 49 50 |
# File 'lib/charles.rb', line 48 def sum return self.inject(0){|accum, i| accum + i } end |