Class: Rack::Mount::Analysis::Histogram

Inherits:
Hash
  • Object
show all
Defined in:
lib/rack/mount/analysis/histogram.rb

Overview

:nodoc:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeHistogram

Returns a new instance of Histogram.



6
7
8
9
10
# File 'lib/rack/mount/analysis/histogram.rb', line 6

def initialize
  @count = 0
  super(0)
  expire_caches!
end

Instance Attribute Details

#countObject (readonly)

Returns the value of attribute count.



4
5
6
# File 'lib/rack/mount/analysis/histogram.rb', line 4

def count
  @count
end

Instance Method Details

#<<(value) ⇒ Object



12
13
14
15
16
17
# File 'lib/rack/mount/analysis/histogram.rb', line 12

def <<(value)
  @count += 1
  self[value] += 1 if value
  expire_caches!
  self
end

#keys_in_upper_quartileObject



43
44
45
# File 'lib/rack/mount/analysis/histogram.rb', line 43

def keys_in_upper_quartile
  @keys_in_upper_quartile ||= compute_keys_in_upper_quartile
end

#maxObject



23
24
25
# File 'lib/rack/mount/analysis/histogram.rb', line 23

def max
  @max ||= values.max || 0
end

#meanObject



31
32
33
# File 'lib/rack/mount/analysis/histogram.rb', line 31

def mean
  @mean ||= calculate_mean
end

#minObject



27
28
29
# File 'lib/rack/mount/analysis/histogram.rb', line 27

def min
  @min ||= values.min || 0
end

#sorted_by_frequencyObject



19
20
21
# File 'lib/rack/mount/analysis/histogram.rb', line 19

def sorted_by_frequency
  sort_by { |_, value| value }.reverse!
end

#standard_deviationObject



35
36
37
# File 'lib/rack/mount/analysis/histogram.rb', line 35

def standard_deviation
  @standard_deviation ||= calculate_standard_deviation
end

#upper_quartile_limitObject



39
40
41
# File 'lib/rack/mount/analysis/histogram.rb', line 39

def upper_quartile_limit
  @upper_quartile_limit ||= calculate_upper_quartile_limit
end