Normal Distribution

Since Silk Performer provides no random type for generating random values that follow a normal distribution, you have to implement your own function for this purpose. The BDL code shown below illustrates how your function should look like.

To use this function, enter exactly the same BDL code in your test script.

Implementation

dclrand
  rUniform01: RndUniF(0.0 .. 1.0);

dclfunc
  function NormalDistribution(fMean, fStd: float): float
  var
    i : number;
    f : float;
  begin
    f := -6.0;
    for i := 1 to 12do
      f := f + rUniform01;
    end;
    NormalDistribution := fMean + fStd*f;
  end NormalDistribution;

Return value

a random value following a normal distribution with the specified mean value and standard deviation

Parameter

Description

fMean Mean value of the normal distribution the generated random value has to follow
fStd Standard deviation of the normal distribution the generated random value has to follow

Example

dcltrans
  transaction TMain
  var
    i: number;
  begin
    for i := 1 to 20 do
      writeln(NormalDistribution(20.0, 2.0));
    end;
  end TMain;

Output

19.756000
16.140000
20.464000
20.844000
19.546000
...