class Statistical::Rng::Laplace
Companion RNG class for the continuous uniform distribution. Requires a
distrbution object of the corresponding distribution
@author Vaibhav Yenamandra
@attr_reader [Numeric] scale Scale parameter of the Laplace
distribution. @attr_reader [Numeric] location Location parameter to determine where the
distribution is centered / where the mean lies at
Attributes
generator[R]
location[R]
scale[R]
Public Class Methods
new(dobj = nil, seed = Random.new_seed)
click to toggle source
# File lib/statistical/rng/laplace.rb, line 16 def initialize(dobj = nil, seed = Random.new_seed) unless dobj.nil? || dobj.is_a?(Statistical::Distribution::Laplace) raise TypeError, "Expected Distribution object or nil, found #{dobj.class}" end dobj = Statistical::Distribution::Laplace.new if dobj.nil? @generator = Random.new(seed) @scale = dobj.scale @location = dobj.location @sdist = dobj end
Public Instance Methods
rand()
click to toggle source
Return the next random number from the sequence
@return next random number in the sequence
# File lib/statistical/rng/laplace.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/laplace.rb, line 49 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/laplace.rb, line 39 def eql?(other) return other.is_a?(self.class) && other.generator == @generator && other.location == @location && other.scale == @scale end
Also aliased as: ==