Class: TDigest::Centroid

Inherits:
Object
  • Object
show all
Defined in:
lib/tdigest/centroid.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(mean, n, cumn, mean_cumn = nil) ⇒ Centroid

Returns a new instance of Centroid.



6
7
8
9
10
11
# File 'lib/tdigest/centroid.rb', line 6

def initialize(mean, n, cumn, mean_cumn = nil)
  @mean      = mean
  @n         = n
  @cumn      = cumn
  @mean_cumn = mean_cumn
end

Instance Attribute Details

#cumnObject

Returns the value of attribute cumn.



5
6
7
# File 'lib/tdigest/centroid.rb', line 5

def cumn
  @cumn
end

#meanObject

Returns the value of attribute mean.



5
6
7
# File 'lib/tdigest/centroid.rb', line 5

def mean
  @mean
end

#mean_cumnObject

Returns the value of attribute mean_cumn.



5
6
7
# File 'lib/tdigest/centroid.rb', line 5

def mean_cumn
  @mean_cumn
end

#nObject

Returns the value of attribute n.



5
6
7
# File 'lib/tdigest/centroid.rb', line 5

def n
  @n
end

Instance Method Details

#as_json(_ = nil) ⇒ Object



13
14
15
# File 'lib/tdigest/centroid.rb', line 13

def as_json(_ = nil)
  { m: mean, n: n }
end