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
#distance(other) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/rust/stats/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
|
#distribution ⇒ Object
142
143
144
145
146
147
148
|
# File 'lib/rust/core/types/datatype.rb', line 142
def distribution
result = {}
self.each do |value|
result[value] = result[value].to_i + 1
end
return result
end
|
138
139
140
|
# File 'lib/rust/core/types/datatype.rb', line 138
def to_R
return "c(#{self.map { |e| e.to_R }.join(",")})"
end
|