g05 Chapter Contents
g05 Chapter Introduction
NAG C Library Manual

# NAG Library Function Documentnag_random_continuous_uniform_ab (g05dac)

## 1  Purpose

nag_random_continuous_uniform_ab (g05dac) returns a pseudorandom real number taken from a uniform distribution over the interval $\left[a,b\right]$.

## 2  Specification

 #include #include
 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 $\left[a,b\right]$.

## 4  References

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

## 5  Arguments

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

None.

Not applicable.

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)

None.

### 9.3  Program Results

Program Results (g05dace.r)