class Statistical::Rng::Gumbel

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/gumbel.rb, line 18
def initialize(dobj = nil, seed = Random.new_seed)
  unless dobj.nil? || dobj.is_a?(Statistical::Distribution::Gumbel)
    raise TypeError,
          "Expected Distribution object or nil, found #{dobj.class}"
  end
  dobj = Statistical::Distribution::Gumbel.new if dobj.nil?
  @generator = Random.new(seed)
  @location = dobj.location
  @scale = dobj.scale
  @sdist = dobj
end

Public Instance Methods

==(other)
Alias for: eql?
rand() click to toggle source

Return the next random number from the sequence

@return [Float] next random number in the sequence

# File lib/statistical/rng/gumbel.rb, line 33
def rand
  @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/gumbel.rb, line 51
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/gumbel.rb, line 41
def eql?(other)
  return other.is_a?(self.class) &&
         @generator == other.generator &&
         @location == other.location &&
         @scale == other.scale
end
Also aliased as: ==