Class: Array

Inherits:
Object
  • Object
show all
Defined in:
lib/zipf/misc.rb

Instance Method Summary collapse

Instance Method Details

#is_subset_of?(other) ⇒ Boolean

Returns:

  • (Boolean)


8
9
10
11
12
13
14
15
# File 'lib/zipf/misc.rb', line 8

def is_subset_of? other
  self.each { |i|
    if other.include? i
     return false
    end
  }
  return true
end

#max_indexObject



4
5
6
# File 'lib/zipf/misc.rb', line 4

def max_index
  self.index(self.max)
end

#meanObject



21
22
23
# File 'lib/zipf/misc.rb', line 21

def mean
  self.sum.to_f/self.size
end

#sumObject



17
18
19
# File 'lib/zipf/misc.rb', line 17

def sum
  self.inject(:+)
end