# Expression functions in 0.3.0-beta1

Some input fields in Junctioneer take Expressions. These expressions can contain calls to built-in functions. This document shows all built-in functions available for expressions in Junctioneer 0.3.0-beta1. For help on how to use expressions, see Expression documentation

Functions that take integer arguments, does actually take floating point values and round them to closest integer value. This is because Expressions only use floating point values internally.

Note that the parentheses are mandatory even for functions that do not take any arguments

## Index

Random numbers:
IntUnif, DoubleUnif, DoublePoisson, DoubleExponential
Math:
PI, Ln
Utility functions:
Min, Max, Abs, Clamp, Round, DecimalsOnly, Floor, Mod
Simulation state:
T, IsPeriodActive, ActivePeriod, PeriodActiveTime, IsTagEnabled

## Random numbers

IntUnif(start, end)Draw a value from a random uniform distribution of integer values from start to end. [Round(start), Round(end)[
DoubleUnif(start, end)Draw a random value from a random uniform distribution of floating point values from start to end. [start, end[
DoublePoisson(mu)Draw a random value from a poison distribution.
DoubleExponential(mu)Draw a random value from a exponential distribution.

## Math

PI()Returns the value of PI. 3.141592...
Ln(x)Ln(x). x must be > 0

## Utility functions

Min(x1, x2)returns the smallest value of x1 and x2
Max(x1, x2)returns the largest value of x1 and x2
Abs(x)absolute value of x
Clamp(value, min, max)clamp value to range [min, max]
Round(x)ronud x to closest integer value
DecimalsOnly(x)returns only the decimals of a floating point value
Floor(x)ronud x down to integer value. Eg. 5.7 => 5
Mod(x, y)returns the integer reminder of the integer division Round(x)/Round(y)

## Simulation state

These functions return zero when simulation is not active. A paused simulation is regarded as active. The simulation state still exist, time is just frozen.

T()returns amount of time since the simulation started in seconds (with decimals).
IsPeriodActive(phase)returns 1 if given schedule period is active, else 0
ActivePeriod()returns id of active schedule period
PeriodActiveTime()returns how long time that the current period has been active
IsTagEnabled(tag)Check if the given traffic light tag is enabled in the current period. The tag argument should be a literal string containing the name of the tag surrounded by quotes. Eg "west". Returns 1 if the tag is enabled, else 0