class EncodingEstimator::RangeScale
Represent a function the maps a value between min and max to 0..1
Public Class Methods
new( min, max )
click to toggle source
Initialize a new object from the range minimum and maximum
@param [Float] min The range's minimum @param [Float] max The range's maximum
# File lib/encoding_estimator/detector.rb, line 16 def initialize( min, max ) @min = min @max = max if max == min @min = min - 1.0 end end
Public Instance Methods
scale( value )
click to toggle source
Map the given value to a range between 0 and 1 (min is 0, max is 1)
@param [Float] value Value to map between 0 and 1
@return [Float] The mapped value between 0 and 1
# File lib/encoding_estimator/detector.rb, line 30 def scale( value ) ( value - @min ) / ( @max - @min ) end