Class: Statistical::Rng::Weibull
- Inherits:
-
Object
- Object
- Statistical::Rng::Weibull
- Defined in:
- lib/statistical/rng/weibull.rb
Overview
Companion RNG class for the continuous uniform distribution. Requires a
distrbution object of the corresponding distribution
Instance Attribute Summary collapse
-
#generator ⇒ Object
readonly
Returns the value of attribute generator.
-
#scale ⇒ Numeric
readonly
The scale parameter of the Weibull distribution.
-
#shape ⇒ Numeric
readonly
The shape parameter of the Weibull distribution.
Instance Method Summary collapse
-
#initialize(dobj = nil, seed = Random.new_seed) ⇒ Weibull
constructor
A new instance of Weibull.
-
#rand ⇒ Object
Return the next random number from the sequence.
-
#type ⇒ Object
Return the type of the source distribution.
Constructor Details
#initialize(dobj = nil, seed = Random.new_seed) ⇒ Weibull
Returns a new instance of Weibull.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/statistical/rng/weibull.rb', line 17 def initialize(dobj = nil, seed = Random.new_seed) unless dobj.nil? || dobj.is_a?(Statistical::Distribution::Weibull) raise TypeError, "Expected Distribution object or nil, found #{dobj.class}" end dobj = Statistical::Distribution::Weibull.new if dobj.nil? @generator = Rng::Uniform.new(Distribution::Uniform.new, seed) @scale = dobj.scale @shape = dobj.shape @sdist = dobj end |
Instance Attribute Details
#generator ⇒ Object (readonly)
Returns the value of attribute generator.
15 16 17 |
# File 'lib/statistical/rng/weibull.rb', line 15 def generator @generator end |
#scale ⇒ Numeric (readonly)
The scale parameter of the Weibull distribution
14 15 16 |
# File 'lib/statistical/rng/weibull.rb', line 14 def scale @scale end |
#shape ⇒ Numeric (readonly)
The shape parameter of the Weibull distribution
14 15 16 |
# File 'lib/statistical/rng/weibull.rb', line 14 def shape @shape end |
Instance Method Details
#rand ⇒ Object
Return the next random number from the sequence
32 33 34 |
# File 'lib/statistical/rng/weibull.rb', line 32 def rand return @sdist.quantile(@generator.rand) end |
#type ⇒ Object
Return the type of the source distribution
50 51 52 |
# File 'lib/statistical/rng/weibull.rb', line 50 def type @sdist.class end |