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

- (Item) initialize(value, g, delta, rank = nil)

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

- (Object) delta

Returns the value of attribute delta



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

def delta
  @delta
end

- (Object) g

Returns the value of attribute g



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

def g
  @g
end

- (Object) rank

Returns the value of attribute rank



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

def rank
  @rank
end

- (Object) value

Returns the value of attribute value



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

def value
  @value
end

Instance Method Details

- (Object) merge(item)



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

- (Object) to_s



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

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