nag_random_exp (g05dbc) (PDF version)
g05 Chapter Contents
g05 Chapter Introduction
NAG C Library Manual

NAG Library Function Document

nag_random_exp (g05dbc)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

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

2  Specification

#include <nag.h>
#include <nagg05.h>
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 lny , 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

1:     adoubleInput
On entry: the argument a  of the distribution. If a is negative, its absolute value is used.

6  Error Indicators and Warnings

None.

7  Accuracy

Not applicable.

8  Further Comments

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)

9.2  Program Data

None.

9.3  Program Results

Program Results (g05dbce.r)


nag_random_exp (g05dbc) (PDF version)
g05 Chapter Contents
g05 Chapter Introduction
NAG C Library Manual

© The Numerical Algorithms Group Ltd, Oxford, UK. 2012