# Random Generator â€‹

A Random generator sets a value to a variable to which it is connected. The value depends on an expression.

Hint

ADOxx provides you with a support dialogue for the definition of these expressions

The syntax of the assignment expressions (*ValAssign*) is based on the following grammar:

ValAssign ::= | MathExpr { ; MathExpr } | ||
---|---|---|---|

MathExpr ::= | Term | ( MathExpr ) | Term Operator MathExpr | |

Term ::= | String | Numeric | Variable | Distrib |

Operator ::= | + | - | * | / |

**Terms:**In the simplest case an assignment expression consists of a single term. There are three possibilities when defining a term: A term can be a**constant**. Depending on the type of the variable this can either be a constant of the type**"Enumeration"**- e.g. 'standard case' - or of the type**"Float"**- e.g. 365. A term can also be**another variable**- e.g. X - of the same type. So the value of the variable can be assigned to another variable. A term can also be a distribution. For variables of type enumeration a distribution type - the discrete distribution - is defined in ADOxx. Three different distribution types exist for variables of type float: exponential, uniform and normal distribution.**Arithmetical expressions:**Using the terms listed above, complex**arithmetical expressions**(*MathExpr*) can be formed. Terms of type float can be combined with the arithmetical operators +,-,* and brackets. The operators * and / take priority over the operators + and -. Terms of type enumeration can be combined using the operator + and brackets if necessary.**Separating a list of assignment expressions:**It is also possible to use more than one expression, by separating them with a semicolon. During the first simulation run, the first expression will be used, during the second run the second, and so on. When there are more runs than expressions, the last expression will be used repeatedly.

**Examples for valid assignment expressions:**

Some examples of valid expressions are now listed. X and Y are variables of type float, while S and T are variables of type enumeration.

Uniform(4; 10) : | the variable is assigned with a random value, based on the distribution used in the example. |
---|---|

X+1 : | the variable is assigned the value X plus 1. |

X+Uniform(4; 10) : | the variable is set to the value of the variable X increased by a random value, based on a uniform distribution. |

X*Exponential(4; 10)+Y : | the value of the variable X is multiplied by a random value (based on an exponential distribution), to this product the variable Y is added. |

S+'a' : | the character 'a' is added to the string S and the result is assigned to the variable. |

'a';S+'b';S+'c' : | during the first run the variable is assigned the character 'a'. During the second run the character 'b' is added to the variable S and the result assigned to the variable. During the third and following runs the character 'c' is added to the variable S and the result assigned to the variable. |