randomExponential

Generates pseudorandom numbers from a standard exponential distribution.

Synopsis

randomExponential (nRandom)

Required Arguments

int nRandom (Input)
Number of random numbers to generate.

Return Value

An array of length nRandom containing the random standard exponential deviates.

Description

Function randomExponential generates pseudorandom numbers from a standard exponential distribution. The probability density function is \(f(x)= e^{-x}\), for \(x>0\). Function randomExponential uses an antithetic inverse CDF technique; that is, a uniform random deviate U is generated, and the inverse of the exponential cumulative distribution function is evaluated at \(1.0-U\) to yield the exponential deviate.

Deviates from the exponential distribution with mean θ can be generated by using randomExponential and then multiplying each entry in r by θ.

Example

In this example, randomExponential generates five pseudorandom deviates from a standard exponential distribution.

from __future__ import print_function
from numpy import *
from pyimsl.stat.randomExponential import randomExponential
from pyimsl.stat.randomSeedSet import randomSeedSet

n_random = 5
randomSeedSet(123457)
r = randomExponential(n_random)
print("Exponential random deviates: %8.4f%8.4f%8.4f%8.4f%8.4f"
      % (r[0], r[1], r[2], r[3], r[4]))

Output

Exponential random deviates:   0.0344  1.3443  0.2662  0.5633  0.1686