Class: FeldtRuby::EuclideanDistance
- Defined in:
- lib/feldtruby/statistics/euclidean_distance.rb
Instance Method Summary collapse
Instance Method Details
#calc(o1, o2) ⇒ Object
4 5 6 7 8 9 10 11 |
# File 'lib/feldtruby/statistics/euclidean_distance.rb', line 4 def calc(o1, o2) sum = 0.0 o1.length.times do |i| d = (o1[i] - o2[i]) sum += (d*d) end Math.sqrt(sum) end |