Class: Array

Inherits:
Object show all
Defined in:
lib/rust/core/types/datatype.rb,
lib/rust/stats/probabilities.rb

Instance Method Summary collapse

Instance Method Details

#_rust_prob_distance(other) ⇒ Object

Computes the distance between this and another array.

Raises:

  • (TypeError)


20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/rust/stats/probabilities.rb', line 20

def _rust_prob_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._rust_prob_distance(shortest[i].to_i)
    end
    
    return distance
end

#distributionObject



176
177
178
179
180
181
182
# File 'lib/rust/core/types/datatype.rb', line 176

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

#to_RObject



172
173
174
# File 'lib/rust/core/types/datatype.rb', line 172

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