class Leafy::Core::Histogram
A metric which calculates the distribution of a value.
@see <a href=“Accurately”>www.johndcook.com/standard_deviation.html“>Accurately computing running variance</a>
Public Class Methods
new(reservoir)
click to toggle source
Creates a new {@link Histogram} with the given reservoir.
@param reservoir the reservoir to create a histogram from
# File lib/leafy/core/histogram.rb, line 15 def initialize(reservoir) @reservoir = reservoir @count = Concurrent::ThreadSafe::Util::Adder.new end
Public Instance Methods
count()
click to toggle source
Returns the number of values recorded.
@return the number of values recorded
# File lib/leafy/core/histogram.rb, line 31 def count @count.sum end
snapshot()
click to toggle source
# File lib/leafy/core/histogram.rb, line 35 def snapshot @reservoir.snapshot end
update(value)
click to toggle source
Adds a recorded value.
@param value the length of the value
# File lib/leafy/core/histogram.rb, line 23 def update(value) @count.increment @reservoir.update(value) end