Module: VectorExtensions
- Included in:
- Vector
- Defined in:
- lib/classifier/extensions/vector.rb
Instance Method Summary collapse
Instance Method Details
#magnitude ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/classifier/extensions/vector.rb', line 21 def magnitude sum_of_squares = 0.to_r size.times do |i| sum_of_squares += self[i]**2.to_r end Math.sqrt(sum_of_squares.to_f) end |