g05 Chapter Contents
g05 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_random_normal (g05ddc)

## 1  Purpose

nag_random_normal (g05ddc) returns a pseudorandom real number taken from a Normal (Gaussian) distribution with mean $a$ and standard deviation $b$.

## 2  Specification

 #include #include
 double nag_random_normal (double a, double b)

## 3  Description

The distribution has PDF (probability density function)
 $f x = 1 b 2π exp - x-a 2 2 b 2 .$
The function uses the method of Brent (1974).

## 4  References

Brent R P (1974) Algorithm 488 Comm. ACM 704
Kendall M G and Stuart A (1969) The Advanced Theory of Statistics (Volume 1) (3rd Edition) Griffin
Knuth D E (1981) The Art of Computer Programming (Volume 2) (2nd Edition) Addison–Wesley

## 5  Arguments

On entry: the mean $a$, of the distribution.
2:     bdoubleInput
On entry: the standard deviation $b$, of the distribution. If b is negative, the distribution of the generated numbers – though not the actual sequence – is the same as if the absolute value of b were used.

None.

Not applicable.

None.

## 9  Example

The example program prints the first five pseudorandom real numbers from a Normal distribution with mean 1.0 and standard deviation 1.5, generated by nag_random_normal (g05ddc) after initialization by nag_random_init_repeatable (g05cbc).

### 9.1  Program Text

Program Text (g05ddce.c)

None.

### 9.3  Program Results

Program Results (g05ddce.r)