Module: Enumerable
- Defined in:
- lib/dsl/monkeypatches.rb
Instance Method Summary collapse
Instance Method Details
#mean ⇒ Object
155 156 157 |
# File 'lib/dsl/monkeypatches.rb', line 155 def mean self.sum/self.length.to_f end |
#sample_variance ⇒ Object
159 160 161 162 163 |
# File 'lib/dsl/monkeypatches.rb', line 159 def sample_variance m = self.mean sum = self.inject(0){|accum, i| accum +(i-m)**2 } sum/(self.length - 1).to_f end |
#standard_deviation ⇒ Object
165 166 167 |
# File 'lib/dsl/monkeypatches.rb', line 165 def standard_deviation return Math.sqrt(self.sample_variance) end |
#sum ⇒ Object
151 152 153 |
# File 'lib/dsl/monkeypatches.rb', line 151 def sum self.inject(0){|accum, i| accum + i } end |