class Statistical::Rng::Exponential
Companion RNG class for the exponential distribution. Requires a
distrbution object of the corresponding distribution
@author Vaibhav Yenamandra
@attr_reader [Numeric] rate Rate parameter of the exponential distribution @attr_reader [Numeric] upper The upper bound of the uniform distribution
Attributes
generator[R]
rate[R]
Public Class Methods
new(dobj = nil, seed = Random.new_seed)
click to toggle source
# File lib/statistical/rng/exponential.rb, line 17 def initialize(dobj = nil, seed = Random.new_seed) unless dobj.nil? || dobj.is_a?(Statistical::Distribution::Exponential) raise TypeError, "Expected Distribution object or nil, found #{dobj.class}" end dobj = Statistical::Distribution::Exponential.new if dobj.nil? @generator = Random.new(seed) @rate = dobj.rate @sdist = dobj end
Public Instance Methods
rand()
click to toggle source
Return the next random number from the sequence
@return [Numeric] next random number in the sequence
# File lib/statistical/rng/exponential.rb, line 31 def rand return @sdist.quantile(@generator.rand) end
type()
click to toggle source
Return the type of the source distribution
@return source distribution's type
# File lib/statistical/rng/exponential.rb, line 48 def type @sdist.class end
Private Instance Methods
eql?(other)
click to toggle source
Compare against another rng to see if they are the same
@return true if and only if, source distributions are the same and the
prng has the same initial state
# File lib/statistical/rng/exponential.rb, line 39 def eql?(other) return other.is_a?(self.class) && @generator == other.generator && @rate = other.rate end
Also aliased as: ==