class RV::Weibull

Weibull generator based on Devroye

Arguments
  • rate -> the scale parameter (rate > 0; default: 1).

  • k -> the shape parameter (k > 0; default: 1).

  • rng -> the (Enumerable) source of U(0, 1)'s (default: U_GENERATOR)

Attributes

k[R]
rate[R]

Public Class Methods

new(rate: 1.0, k: 1.0, rng: U_GENERATOR) click to toggle source
# File lib/random_variates.rb, line 331
def initialize(rate: 1.0, k: 1.0, rng: U_GENERATOR)
  raise 'Rate and k must be positive.' if rate <= 0 || k <= 0

  @rate = rate
  @k = k
  @rng = rng
  @power = 1.0 / k
end

Public Instance Methods

next() click to toggle source
# File lib/random_variates.rb, line 340
def next
  (-Math.log(@rng.next))**@power / @rate
end