Class: Item

Inherits:
Object
  • Object
show all
Defined in:
lib/quantile_estimator/item.rb

Overview

n = items k = asymptote S = data structure containing multiple tuples s = samples of items from the data stream

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, g, delta, rank = nil) ⇒ Item

Returns a new instance of Item.



7
8
9
10
11
12
# File 'lib/quantile_estimator/item.rb', line 7

def initialize(value, g, delta, rank=nil)
  self.value = value
  self.g = g
  self.delta = delta
  self.rank  = rank
end

Instance Attribute Details

#deltaObject

Returns the value of attribute delta.



6
7
8
# File 'lib/quantile_estimator/item.rb', line 6

def delta
  @delta
end

#gObject

Returns the value of attribute g.



6
7
8
# File 'lib/quantile_estimator/item.rb', line 6

def g
  @g
end

#rankObject

Returns the value of attribute rank.



6
7
8
# File 'lib/quantile_estimator/item.rb', line 6

def rank
  @rank
end

#valueObject

Returns the value of attribute value.



6
7
8
# File 'lib/quantile_estimator/item.rb', line 6

def value
  @value
end

Instance Method Details

#merge(item) ⇒ Object



14
15
16
# File 'lib/quantile_estimator/item.rb', line 14

def merge(item)
  Item.new(item.value, self.g + item.g, item.delta, item.rank)
end

#to_sObject



18
19
20
# File 'lib/quantile_estimator/item.rb', line 18

def to_s
  [value, g, delta, rank].inspect
end