nag_random_continuous_uniform_ab (g05dac) (PDF version)
g05 Chapter Contents
g05 Chapter Introduction
NAG C Library Manual

NAG Library Function Document

nag_random_continuous_uniform_ab (g05dac)

+ Contents

    1  Purpose
    7  Accuracy

1  Purpose

nag_random_continuous_uniform_ab (g05dac) returns a pseudorandom real number taken from a uniform distribution over the interval a,b .

2  Specification

#include <nag.h>
#include <nagg05.h>
double  nag_random_continuous_uniform_ab (double a, double b)

3  Description

This distribution has PDF (probability density function)
f x = 1 / a-b if   x a,b f x = 0 otherwise.
The function returns the value
x = a + b-a y
where y  is a pseudorandom number from a uniform distribution over (0,1), generated by nag_random_continuous_uniform (g05cac). The function ensures that x  lies in the closed interval a,b .

4  References

Knuth D E (1981) The Art of Computer Programming (Volume 2) (2nd Edition) Addison–Wesley

5  Arguments

1:     adoubleInput
2:     bdoubleInput
On entry: the end-points a  and b  of the distribution. It is not necessary that a<b .

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 uniform distribution between 1.0 and 1.5, generated by nag_random_continuous_uniform_ab (g05dac) after initialization by nag_random_init_repeatable (g05cbc).

9.1  Program Text

Program Text (g05dace.c)

9.2  Program Data

None.

9.3  Program Results

Program Results (g05dace.r)


nag_random_continuous_uniform_ab (g05dac) (PDF version)
g05 Chapter Contents
g05 Chapter Introduction
NAG C Library Manual

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