Random_Exponential Routines
Function generates a Random Variate in [0, Infinity) from a negative exponential distribution with density proportional to EXP (-random_exponential), using Inversion.

Unit
QESBPCSRandom

Overloaded Variants
Function Random_Exponential: Extended;
Function Random_Exponential(RandomGenerator: TRandomGenFunction): Extended;

Declaration
Function Random_Exponential: Extended;

Description
Adapted from Fortran 77 code from the book: Dagpunar, J. 'Principles of random variate generation' Clarendon Press, Oxford, 1988. ISBN 0-19-852202-9

Parameters
RandomGenerator Optional Function to use for Uniform Random Number Generator. If omitted, Delphi's Random function is used, and if this is done remember to call Randomize if you don't want repeated values.

Category
Arithmetic Routines for Floats

Implementation

function Random_Exponential: Extended;
begin
     Result := Random_Exponential (DelphiRandom);
End;

Declaration
Function Random_Exponential(RandomGenerator: TRandomGenFunction): Extended;

Implementation

function Random_Exponential (RandomGenerator: TRandomGenFunction): Extended;
var
     r: Extended;
     Done: Boolean;
begin
     Done := False;
     repeat
          r := RandomGenerator;
          if (r > vSmall) then
               Done := True;
     until Done;
     Result := -Ln (r)
End;


HTML generated by Time2HELP
http://www.time2help.com