randomWeibull

Generates pseudorandom numbers from a Weibull distribution.

Synopsis

randomWeibull (nRandom, a)

Required Arguments

int nRandom (Input)
Number of random numbers to generate.
float a (Input)
Shape parameter of the Weibull distribution. This parameter must be positive.

Return Value

An array of length nRandom containing the random deviates of a Weibull distribution.

Optional Arguments

b, float (Input)

Scale parameter of the two parameter Weibull distribution.

Default: b = 1.0

Description

Function randomWeibull generates pseudorandom numbers from a Weibull distribution with shape parameter a and scale parameter b. The probability density function is

f(x)=abxa1exp(bxa)

for x0, a>0, and b>0. Function randomWeibull uses an antithetic inverse CDF technique to generate a Weibull variate; that is, a uniform random deviate U is generated and the inverse of the Weibull cumulative distribution function is evaluated at 1.0U to yield the Weibull deviate.

Note that the Rayleigh distribution with probability density function

r(x)=1α2xe(x2/(2α2))

for x ≥ 0 is the same as a Weibull distribution with shape parameter a equal to 2 and scale parameter b equal to

2α

Example

In this example, randomWeibull is used to generate five pseudorandom deviates from a two-parameter Weibull distribution with shape parameter equal to 2.0 and scale parameter equal to 6.0—a Rayleigh distribution with the following parameter:

α=32
from numpy import *
from pyimsl.stat.randomWeibull import randomWeibull
from pyimsl.stat.randomSeedSet import randomSeedSet
from pyimsl.stat.writeMatrix import writeMatrix

n_random = 5
a = 3.0
randomSeedSet(123457)
r = randomWeibull(n_random, a)
writeMatrix("Weibull random deviates", r, noColLabels=True)

Output

 
                    Weibull random deviates
      0.325        1.104        0.643        0.826        0.552

Warning Errors

IMSLS_SMALL_A The shape parameter is so small that a relatively large proportion of the values of deviates from the Weibull cannot be represented.