Sha256: 89b191d89f845e910498ea37d029205b80acb1376316dab37124f7cfe663a260
Contents?: true
Size: 732 Bytes
Versions: 1
Compression:
Stored size: 732 Bytes
Contents
# frozen_string_literal: true module DDSketch module Mapping # A memory-optimal KeyMapping, i.e., given a targeted relative accuracy, it # requires the least number of keys to cover a given range of values. This is # done by logarithmically mapping floating-point values to integers. class LogarithmicKeyMapping < KeyMapping # (see KeyMapping#initialize) def initialize(relative_accuracy:, offset: 0.0) super(relative_accuracy: relative_accuracy, offset: offset) @multiplier *= Math.log(2) end protected def log_gamma(value) Math.log(value, 2) * @multiplier end def pow_gamma(value) 2**(value / @multiplier) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ddsketch-0.1.0 | lib/ddsketch/mapping/logarithmic_key_mapping.rb |