RndBin Random Type (binomial distribution)

Action

Declares a random variable of type RndBin. With each access, such a variable contains a boolean value that is generated following a binomial (Bernoulli) distribution. The parameter of the RndBin random type specifies the probability of returning true. For example, you can use a random variable using the RndBin random type to specify the probability of running transaction components.

Syntax

RndBin( in p : float ): boolean;

Return value

  • true or

  • false

Parameter Description
p

Probability of returning true

Condition: 0.0 <= p <= 1.0

Example

dclrand
  rEvent1, rEvent2: RndBin(0.25);

dcltrans
  transaction TMain
  begin
    if rEvent1 then ... end;

    while not rEvent2 do ... end;
  end TMain;

The example shows two random variables with Bernoulli distribution (rEvent1 and rEvent2). In both cases the probability of returning true is 0.25. This means that on average rEvent1 will be set to true in 25% of all cases, and the same applies for rEvent2.

Note: As each use of a random variable generates a new random value, you must assign the value of a random variable to a transaction variable in order to be able to reuse this value.

Sample scripts

OraSample.bdf, DBApi01.bdf