Main Content

wblrnd

Weibull random numbers

Description

r = wblrnd(a,b) generates a random number from the Weibull distribution with scale a and shape b.

example

r = wblrnd(a,b,sz1,...,szN) generates an array of random numbers from the Weibull distribution, where sz1,...,szN indicates the size of each dimension.

example

r = wblrnd(a,b,sz) generates an array of random numbers from the Weibull distribution where size vector sz specifies size(r).

example

Examples

collapse all

Generate a single random number from the Weibull distribution with scale 4 and shape 3.

r = wblrnd(4,3)
r = 
2.3582

Generate a 1-by-5 array of random numbers drawn from the Weibull distributions with scale 3 and shape values 1 through 5.

a1 = 3;
b1 = 1:5;
r1 = wblrnd(a1,b1)
r1 = 1×5

    0.6147    0.9437    3.8195    1.6459    2.5666

If you specify array dimensions, they must match the dimensions of a and b after any scalar expansion.

Generate a 1-by-6 array of random numbers drawn from the Weibull distributions with scale values 1 through 6 and shape values 5 through 10, respectively.

a2 = 1:6;
b2 = 5:10;
sz1 = 1;
sz2 = 6;
r2 = wblrnd(a2,b2,sz1,sz2)
r2 = 1×6

    1.1841    2.0836    2.7912    2.7026    3.4531    6.3799

Generate a 2-by-3 array of random numbers from the Weibull distribution with scale 4 and shape 5.

sz = [2 3];
r3 = wblrnd(4,5,sz)
r3 = 2×3

    1.9817    3.7486    4.5729
    2.1395    2.9624    3.8841

Input Arguments

collapse all

Scale parameter of the Weibull distribution, specified as a positive scalar value or an array of positive scalar values.

To generate random numbers from multiple distributions, specify a and b using arrays. If either or both of the input arguments a and b are arrays, then the array sizes must be the same. In this case, wblrnd expands each scalar input into a constant array of the same size as the array inputs. Each element in r is the random number generated from the distribution specified by the corresponding elements in a and b.

Example: [1 2 3 5]

Data Types: single | double

Shape parameter of the Weibull distribution, specified as a positive scalar value or an array of positive scalar values.

To generate random numbers from multiple distributions, specify a and b using arrays. If either or both of the input arguments a and b are arrays, then the array sizes must be the same. In this case, wblrnd expands each scalar input into a constant array of the same size as the array inputs. Each element in r is the random number generated from the distribution specified by the corresponding elements in a and b.

Example: [1 1 2 2]

Data Types: single | double

Size of each dimension, specified as separate arguments of integers.

If a and b are arrays, then the specified dimensions sz1,...,szN must match the dimensions of a and b. The default values of sz1,...,szN are the dimensions of a and b.

  • If you specify a single value sz1, then r is a square matrix of size sz1-by-sz1.

  • If the size of any dimension is 0 or negative, then r is an empty array.

  • Beyond the second dimension, wblrnd ignores trailing dimensions with a size of 1. For example, wblrnd(2,5,3,1,1,1) produces a 3-by-1 vector of random numbers from the distribution with scale 2 and shape 5.

Example: 3,5

Data Types: single | double

Size of each dimension, specified as a row vector of integers.

If a and b are arrays, then the specified dimensions sz must match the dimensions of a and b. The default values of sz are the dimensions of a and b.

  • If you specify a single value [sz1], then r is a square matrix of size sz1-by-sz1.

  • If the size of any dimension is 0 or negative, then r is an empty array.

  • Beyond the second dimension, wblrnd ignores trailing dimensions with a size of 1. For example, wblrnd(2,5,[3 1 1 1]) produces a 3-by-1 vector of random numbers from the distribution with scale 2 and shape 5.

Example: [3 5]

Data Types: single | double

Output Arguments

collapse all

Weibull random numbers, returned as a scalar value or an array of scalar values with the dimensions specified by sz1,...,szN or sz. Each element in r is the random number generated from the distribution specified by the corresponding elements in a and b.

Alternative Functionality

  • wblrnd is a function specific to the Weibull distribution. Statistics and Machine Learning Toolbox™ also offers the generic function random, which supports various probability distributions. To use random, specify the probability distribution name and its parameters. Note that the distribution-specific function wblrnd is faster than the generic function random.

  • To generate random numbers interactively, use randtool, a user interface for random number generation.

Extended Capabilities

Version History

Introduced before R2006a