Class: Array

Inherits:
Object show all
Defined in:
lib/rust-core.rb,
lib/rust-probabilities.rb

Instance Method Summary collapse

Instance Method Details

#distance(other) ⇒ Object

Raises:

  • (TypeError)


12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/rust-probabilities.rb', line 12

def distance(other)
    raise TypeError, "no implicit conversion of #{other.class} into Array" unless other.is_a? Array
    
    longest, shortest = self.size > other.size ? [self, other] : [other, self]
    
    distance = 0
    for i in 0...longest.size
        distance += longest[i].to_i.distance(shortest[i].to_i)
    end
    
    return distance
end

#distributionObject



800
801
802
803
804
805
806
# File 'lib/rust-core.rb', line 800

def distribution
    result = {}
    self.each do |value|
        result[value] = result[value].to_i + 1
    end
    return result
end

#to_RObject



796
797
798
# File 'lib/rust-core.rb', line 796

def to_R
    return "c(#{self.map { |e| e.to_R }.join(",")})"
end