nag_random_normal (g05ddc) (PDF version)
g05 Chapter Contents
g05 Chapter Introduction
NAG C Library Manual

NAG Library Function Document

nag_random_normal (g05ddc)

+ Contents

    1  Purpose
    7  Accuracy

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

1:     adoubleInput
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.

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 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)

9.2  Program Data

None.

9.3  Program Results

Program Results (g05ddce.r)


nag_random_normal (g05ddc) (PDF version)
g05 Chapter Contents
g05 Chapter Introduction
NAG C Library Manual

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