Class: ANTLR3::Profile::DataSet
- Includes:
- Math
- Defined in:
- lib/antlr3/profile.rb
Instance Method Summary collapse
Methods inherited from Array
Instance Method Details
#average ⇒ Object
81 82 83 |
# File 'lib/antlr3/profile.rb', line 81 def average length > 0 ? ( total.to_f / length ) : 0 end |
#standard_deviation ⇒ Object
89 90 91 |
# File 'lib/antlr3/profile.rb', line 89 def standard_deviation sqrt( variance ) end |
#total ⇒ Object
78 79 80 |
# File 'lib/antlr3/profile.rb', line 78 def total inject( :+ ) end |
#variance ⇒ Object
84 85 86 87 88 |
# File 'lib/antlr3/profile.rb', line 84 def variance length.zero? and return( 0.0 ) mean = average inject( 0.0 ) { |t, i| t + ( i - mean )**2 } / ( length - 1 ) end |