FreeMat

- Main Page
- Related Pages

RANDNCHI Generate Noncentral Chi-Square Random Variable

Section: Random Number Generation

# Usage

Generates a vector of non-central chi-square random variables with the given number of degrees of freedom and the given non-centrality parameters. The general syntax for its use is

       y = randnchi(n,mu)

where `n` is an array containing the degrees of freedom for each generated random variable (with each element of `n` >= 1), and `mu` is the non-centrality shift (must be positive).

# Internals

A non-central chi-square random variable is the sum of a chisquare deviate with `n-1` degrees of freedom plus the square of a normal deviate with mean `mu` and standard deviation 1.

# Examples

Here is an example of a non-central chi-square random variable:

    --> randnchi(5*ones(1,9),0.3)

    ans =

     Columns 1 to 7

       12.8187    1.5030    1.9084    3.6028    1.1185    4.1872    4.5202

     Columns 8 to 9

        3.4539    0.4578