HyperMath

Chi2Rnd

Chi2Rnd

Previous topic Next topic No expanding text in this topic  

Chi2Rnd

Previous topic Next topic JavaScript is required for expanding text JavaScript is required for the print function  

Generates random data from the chi squared probability distribution. There are two forms.

Syntax

RND = Chi2Rnd(n, Rows, Cols, Seed, State)

RND = Chi2Rnd(n, Seed, State)

Arguments

Name

Description

 

n

Degrees of freedom parameter. A scalar, vector or matrix of positive integers.

 

Rows

(optional)

Number of output rows. A positive integer. Only valid when n is a scalar.

 

Cols

(optional)

Number of output columns. A positive integer. Only valid when n is a scalar.

 

Seed

(optional)

The seed to initialize the random number generator. An integer. See Comments below.

 

State

(optional)

Set to "discard" if the state of the pseudo random number is not to be retained for future use. The default is "retain".

Outputs

Name

Description

 

RND

Random numbers from the chi squared distribution. Its dimensions are determined by the input arguments. See Comments below.

Example 1

Generate two random numbers from the chi squared distribution with n = 5 and 3 respectively, with a random seed of 2003

 

Syntax

 

rnd = Chi2Rnd([5,3],2003)

 

Results

 

rnd = 3.5434    2.425

Example 2

Generate a 1x4 vector of random numbers from the chi squared distribution with n = 5 and random seed of 2003.

 

Syntax

 

rnd = Chi2Rnd(5,1,4,2003)

 

Results

 

rnd = 3.5434    4.0417    4.5178    5.3009

Comments

If the optional size inputs are omitted, the size of the output is solely determined by the size of the input n. Each entry in the output uses the corresponding entries in the input n.

 

If the optional size inputs are provided, both must be supplied. In that case, n must be a scalar and the size of the output is determined by Rows and Cols. That is, the input n is used for each element of the output.

 

The Seed can be any number. Using a seed allows a random sequence to be repeated.

See Also:

Chi2CDF

Chi2InvCDF

Chi2PDF

Probability Distributions