Random_Cauchy Routines
Generate a random variant from the standard Cauchy distribution.

Unit
QESBPCSRandom

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

Declaration
Function Random_Cauchy: Extended;

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_Cauchy: Extended;
begin
     Result := Random_Cauchy (DelphiRandom);
End;

Declaration
Function Random_Cauchy(RandomGenerator: TRandomGenFunction): Extended;

Implementation

function Random_Cauchy (RandomGenerator: TRandomGenFunction): Extended;
var
     V1, V2: Extended;
begin
     repeat
          V1 := 2.0 * (RandomGenerator - 0.5);
          V2 := 2.0 * (RandomGenerator - 0.5);
     until (Abs (V2) > VSmall) and (Sqr (V1) + Sqr (V2) < 1.0);
     Result := V1 / V2;
End;


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