Class: ERV::WeibullDistribution
- Inherits:
-
Distribution
- Object
- Distribution
- ERV::WeibullDistribution
- Defined in:
- lib/erv/weibull_distribution.rb
Constant Summary
Constants inherited from Distribution
Instance Method Summary collapse
-
#initialize(opts = {}) ⇒ WeibullDistribution
constructor
A new instance of WeibullDistribution.
-
#sample ⇒ Object
For more details, see [KROESE11], section 4.2.18, algorithm 4.66 and.
Constructor Details
#initialize(opts = {}) ⇒ WeibullDistribution
Returns a new instance of WeibullDistribution.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/erv/weibull_distribution.rb', line 5 def initialize(opts = {}) super(opts) raise ArgumentError unless opts[:scale] and opts[:shape] @scale = opts[:scale].to_f @shape = opts[:shape].to_f raise ArgumentError, 'scale parameter must be greater than zero!' unless @scale > 0.0 raise ArgumentError, 'shape parameter must be greater than zero!' unless @shape > 0.0 end |
Instance Method Details
#sample ⇒ Object
For more details, see [KROESE11], section 4.2.18, algorithm 4.66 and
18 19 20 21 |
# File 'lib/erv/weibull_distribution.rb', line 18 def sample u = @rng.rand @scale * (-Math.log(1 - u))**(1.0 / @shape) end |