g05 Chapter Contents
g05 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_random_exp (g05dbc)

## 1  Purpose

nag_random_exp (g05dbc) returns a pseudorandom real number taken from a (negative) exponential distribution with mean $a$.

## 2  Specification

 #include #include
 double nag_random_exp (double a)

## 3  Description

The distribution has PDF (probability density function)
 $f x = 1 a e - x / a if x > 0 f x = 0 ​ otherwise.$
The function returns the value $-a\mathrm{ln}y$, where $y$ is a pseudorandom number from a uniform distribution over (0,1), generated by nag_random_continuous_uniform (g05cac).

## 4  References

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 argument $a$ of the distribution. If a is negative, its absolute value is used.

None.

Not applicable.

None.

## 9  Example

The example program prints the first five pseudorandom real numbers from a negative exponential distribution with mean 2.0, generated by nag_random_exp (g05dbc) after initialization by nag_random_init_repeatable (g05cbc).

### 9.1  Program Text

Program Text (g05dbce.c)

None.

### 9.3  Program Results

Program Results (g05dbce.r)