Module: Enumerable
- Defined in:
- lib/ms/curvefit/curve_fit_helper.rb
Instance Method Summary collapse
- #mean ⇒ Object
- #sample_variance(mean) ⇒ Object
- #standard_deviation(mean = self.mean) ⇒ Object
- #sum ⇒ Object
Instance Method Details
#mean ⇒ Object
10 11 12 |
# File 'lib/ms/curvefit/curve_fit_helper.rb', line 10 def mean self.sum/self.length.to_f end |
#sample_variance(mean) ⇒ Object
14 15 16 17 18 |
# File 'lib/ms/curvefit/curve_fit_helper.rb', line 14 def sample_variance(mean) m = mean sum = self.inject(0){|accum, i| accum +(i-m)**2 } sum/(self.length - 1).to_f end |
#standard_deviation(mean = self.mean) ⇒ Object
20 21 22 |
# File 'lib/ms/curvefit/curve_fit_helper.rb', line 20 def standard_deviation(mean = self.mean) return Math.sqrt(self.sample_variance(mean)) end |
#sum ⇒ Object
6 7 8 |
# File 'lib/ms/curvefit/curve_fit_helper.rb', line 6 def sum self.inject(0){|accum, i| accum + i } end |