class Statistical::Rng::Bernoulli

This class models a bernoulli trial using the TwoPoint distribution as as base distribution / trial system.

Public Class Methods

new(dobj = nil, seed = Random.new_seed) click to toggle source

Companion RNG class for the Bernoulli distribution. Requires a distrbution object of the same type. Defaults to standard bernoulli if arguments are unspecified

@author Vaibhav Yenamandra

@attr_reader [Float] p Probability of success state @attr_reader [Float] q Probability of failure state @attr_reader [Hash] states Possible states that the RNG can take up @attr_reader [Random] generator The PRNG being used for randomness

Calls superclass method
# File lib/statistical/rng/bernoulli.rb, line 19
def initialize(dobj = nil, seed = Random.new_seed)
  unless dobj.nil? || dobj.is_a?(Statistical::Distribution::Bernoulli)
    raise TypeError,
          "Expected Distribution object or nil, found #{dobj.class}"
  end
  dobj = Statistical::Distribution::Bernoulli.new if dobj.nil?
  super(dobj, seed)
end