RndInd Random Type (individual distribution)

Action

Declares a random variable of type RndInd. With each access, such a variable contains a random value whose type is either string or integer, depending on the syntax of your declaration. All possible values of the random variable along with their probabilities/weights must be declared. You cannot mix integer and string values.

Note: Not only probalities which must sum up to 1.0 are allowed as parameters. Also weights can be used; but they are internally also used as probabilities."

Sytax

RndInd( s1=p1, ..., sn=pn ): string;
RndInd( u1=p1, ..., un=pn ): number;

Return value

  • string or

  • number

Parameter Description
s1 First random value (string)
u1 First random value (number)
p1 Probability/weight of the first random value (float)
sn nth random value (string)
un nth random value (number)
pn

Probability/weight of the nth random value (float)

Condition: p i = 1;

Example

dclrand
  rMaritalStat : RndInd("single" =0.4, "married"=0.3,
                        "divorced"=0.2, "widowed"=0.1);
  rMark : RndInd(1=0.1, 2=0.2, 3=0.3, 4=0.2, 5=0.2);
  ... 

dclsql
  InsPerson:
    INSERT INTO person (name, maritalstatus)
    VALUES (:rName, :rMaritalStat);
  InsExam:
    INSERT INTO exam (name, mark)
    VALUES (:rName, :rMark);

The random variable rMaritalStat is used in a SQL command to generate random values for the database field marital status. The probabilities/weights of the values for marital status are: 40% "single", 30% "married", 20% "divorced", and 10% "widowed". The random variable rMark is used in a SQL command to generate random values for the database field mark. The probabilities/weights of the values for mark are: 10% 1, 20% 2, 30% 3, 20% 4 and 20% 5.

Sample scripts

OraArrayFetch.bdf, OraSample.bdf, DBApi01.bdf