IDistribution.Random

Syntax

Random: Double;

Description

The Random property returns a random number corresponding to a distribution.

Example

Sub Main;

Var

Distr: IDistribution;

Uniform: SmUniformDistribution;

Values: Array Of Double;

d0: Double;

i: Integer;

Const Cnt = 10;

Begin

Uniform := New SmUniformDistribution.Create;

Uniform.A := 0.8;

Uniform.B := 1.4;

Distr := Uniform;

Values := Distr.RandomVector(Cnt);

For i := 0 To Values.Length - 1 Do

d0 := Values[i];

Debug.WriteLine(d0);

End For;

Debug.WriteLine("Random number: " + d0.ToString);

End Sub Main;

After executing the example the console window displays random number vector and the random number corresponding to distribution:

Module execution started

0,911778846396135

0,877283664348858

1,03688794936663

0,84031554890119

1,20733516981687

0,945066287883757

0,911692362304475

1,33253351129991

1,23526571457029

1,36281494710662

Random number: 1.1489066521905988

Module execution finished

See also:

IDistribution