Attribute values

This section presents the possible distributions that can be assigned to the attributes of the simulation objects. A distribution is defined in the form of a list. The first element of the list is always a string of length 1, which serves as an identifier for the different distributions. The remaining attributes define the specific distribution parameters.

Distribution

Identifier

Parameters

User defined

/

/

Fix

f

[“f”, \(\nu\) ]

Binary

b

[“b”, p ]

Binomial

i

[“i”, n , p ]

Normal

n

[“n”, \(\mu\) , \(\sigma\) ]

Uniform

u

[“u”, a , b ]

Poisson

p

[“p”, \(\lambda\) ]

Exponential

e

[“e”, \(\beta\) ]

Lognormal

l

[“l”, \(\mu\) , \(\sigma\) ]

Chisquare

c

[“c”, n ]

Standard-t

t

[“t”, n ]


User defined

If the desired distribution is not predefined, then the user can define custom distribution functions. Such a function is defined in the global scope of the function input file. The function’s name later serves as an identifier and thus must have length 1 and not intersect with the predefined ones. Since the return value of such a function is assigned to the attributes, the return type must be int or float. However, the defined function can have any number of arguments of any type. In the distribution list, the arguments of this function are then passed in the same order.

Example:

The task is to define the following distribution function, which is not predefined, and then assign it to an attribute.

\[\begin{split}P(X=x) = \left\{\begin{array}{ll} \frac{1}{2} & ;x=0.9 \\ \frac{1}{4} & ;x=1.8 \\ \frac{1}{8} & ;x=2.9 \\ \frac{1}{8} & ;x=6 \\ 0 & ;else\\ \end{array}\right.\end{split}\]

It is possible to define a function that uses the values shown. Alternatively, a general function is defined that can be used to map other arbitrary discrete distributions. For this purpose, x is used as a free identifier and choice from numpy.random as distribution. The attributes of the function x are two lists that contain the probabilities and discrete values.

from numpy.random import choice

def x(values, probabilities) -> Union[int, float]:
   return choice(a=values, p=probabilities)

Now, this distribution needs to be added to the attribute.

"attr_1": ["x",[0.9,1.8,2.9,6],[0.5,0.25,0.125,0.125]]
distribution_normal

Note

User-defined distributions are not checked by the inspector.


Fixed

The identifier f indicates a fixed attribute value. The second parameter of the list specifies the fixed value \(\nu\) that the attribute takes. Like all other attributes, the types int and float are possible. Distribution:

Distribution:

\[P(x=\nu)=1\ ,\hspace{0.2cm} \nu\in\mathbb{R}\]

Example:

"prob_of_failure": ["f",4.34]
distribution_normal

Overview:

Value

Explanation

Identifier

f

Additional parameter

\(\nu\)

Value

Exceptions

InvalidFormat

List does not have length 2

InvalidType

\(\nu\) is not of type int or float


Binary

The identifier b indicates a binary attribute value. The second element of the list is the probability p that the attribute takes the value 1. B(k,p) indicates the probability that an attribute takes the values k, given probability p.

Distribution:

\[\begin{split}B(k,p) = \left\{\begin{array}{ll} p^k(1-p)^{1-k} & ;k\in\lbrace0,1\rbrace \\ 0 & ;else\end{array}\right.\ ,\hspace{0.2cm} p\in\lbrack0,1\rbrack\end{split}\]

Example:

"attr_1": ["b",0.2]
distribution_binary

Overview:

Value

Explanation

Identifier

b

Additional parameter

p

Success probability

Exceptions

InvalidFormat

List does not have length 2

InvalidType

p is not of type int or float

InvalidValue

p is not between 0.0 and 1.0


Binomial

The identifier i indicates a binomial attribute value. The second list element is the number of trails n, while the third is the success probability p. B(k,p) indicates the probability that an attribute takes the values k, given probability p and the number of trails n.

Distribution:

\[\begin{split}B(k,n,p) = \left\{\begin{array}{ll}\binom{n}{k} p^k(1-p)^{1-k} & ;k\in\lbrace0,..,n\rbrace \\ 0 & ;else\end{array}\right.\ ,\hspace{0.2cm} p\in\lbrack0,1\rbrack\end{split}\]

Example:

"attr_1": ["i",5,0.4]
distribution_binomial

Overview:

Value

Explanation

Identifier

i

Additional parameter

n

Number of trails

Additional parameter

p

Success probability for each trail

Exceptions

InvalidFormat

List does not have length 2

InvalidType

n is not of type int

p is not of type int or float

InvalidValue

n is not greater than zero

p is not between 0.0 and 1.0


Normal

The identifier n indicates a normally distributed attribute. The second list entry corresponds to the mean \(\mu\) and the third to the standard deviation \(\sigma\).

Distribution:

\[p(x)=\frac{1}{\sqrt{2\pi\sigma^2}}e^{-\frac{(x-\mu)^2}{2\sigma^2}}\ ;\hspace{0.2cm} x,\mu\in\mathbb{R},\ \sigma\ge 0\]

Example:

"attr_1": ["n",4,2.5]
distribution_normal

Overview:

Value

Explanation

Identifier

n

Additional parameter

\(\mu\)

Mean

\(\sigma\)

Standard deviation

Exceptions

InvalidFormat

List does not have length 3

InvalidType

\(\mu\) or \(\sigma\) is not of type int or float

InvalidValue

\(\sigma\) is smaller than zero


Uniform

The identifier u indicates a uniform distributed attribute. The second list parameter a is the lower limit, while the third b sets the upper interval limit. The limits can be integers or floating-point numbers.

Distribution:

\[\begin{split}p(x) = \left\{\begin{array}{ll}\frac{1}{b-a} & ;x\in\lbrack b,..,a) \\ 0 & ;else\end{array}\right.\ ;\hspace{0.2cm} a,b\in\mathbb{R},\ b>a\end{split}\]

Example:

"attr_1": ["u",1,2.34]
distribution_normal

Overview:

Value

Explanation

Identifier

u

Additional parameter

a

lower bound

a

upper bound

Exceptions

InvalidFormat

List does not have length 3

InvalidType

a or b is not of type float or int

InvalidValue

a is greater or equal b


Poisson

The identifier p indicates a Poisson-distributed attribute. The second list entry determines the rate \(\lambda\), which must be type float or int and greater than or equal to zero. \(P(k,\lambda)\)lambda`.

Distribution:

\[\begin{split}P(k,\lambda) = \left\{\begin{array}{ll}\frac{\lambda^ke^{-\lambda}}{k!} & ;k\in\mathbb{N}_{\ge0} \\ 0 & ;else\end{array}\right.\ ,\hspace{0.2cm} \lambda>0\end{split}\]

Example:

"attr_1": ["p",2.1]
distribution_normal

Overview:

Value

Explanation

Identifier

p

Additional parameter

\(\lambda\)

Rate

Exceptions

InvalidFormat

List does not have length 2

InvalidType

\(\lambda\) is not of type float or int

InvalidValue

\(\lambda\) is less than zero


Exponential

The identifier e indicates an exponential distributed attribute. The second list element is the scale \(\beta\), which can be a positive floating-point number.

Distribution:

\[\begin{split}p(x) = \left\{\begin{array}{ll} \frac{1}{\beta} e^{-\frac{x}{\beta}} & ;x \ge 0 \\ 0 & ;else\end{array}\right.\ ,\hspace{0.2cm} \beta\in\mathbb{R}_{>0}\end{split}\]

Example:

"attr_1": ["e",2.5]
distribution_normal

Overview:

Value

Explanation

Identifier

e

Additional parameter

\(\beta\)

Scale

Exceptions

InvalidFormat

List does not have length 2

InvalidType

\(\beta\) is not of type float or int

InvalidValue

\(\beta\) is less or equal to zero

Note

Often the exponential function is also defined by the rate \(\lambda=\frac{1}{\beta}\), instead of the scale \(\beta\). For more information see numpy.random.exponential.


Lognormal

The identifier l indicates a lognormal distributed attribute. The second list entry corresponds to the mean \(\mu\) and the third to the standard deviation \(\sigma\); \(\mu\) and \(\sigma\) must be of type int or float, while \(\sigma\) must also be greater than or equal to zero.

Distribution:

\[\begin{split}p(x) = \left\{\begin{array}{ll} \frac{1}{\sigma x \sqrt{2\pi}}e^{-\frac{(\ln{x}-\mu)^{2}}{2\sigma^{2}}} & ;x > 0 \\ 0 & ;else\end{array}\right.\ ,\hspace{0.2cm} \mu\in\mathbb{R},\ \sigma\in\mathbb{R}_{>0}\end{split}\]

Example:

"attr_1": ["l",0,0.5]
distribution_normal

Overview:

Value

Explanation

Identifier

l

Additional parameter

\(\mu\)

Mean

\(\sigma\)

Standard deviation

Exceptions

InvalidFormat

List does not have length 3

InvalidType

\(\mu\) or \(\sigma\) is not of type float or int

InvalidValue

\(\sigma\) is less than zero


Chisquare

The identifier c indicates a chi-square distributed attribute. The second list entry determines the degrees of freedom n, which must be a positive floating-point or integer.

Distribution:

\[\begin{split}p_{n}(x) = \left\{\begin{array}{ll} \frac{1}{2^{\frac{n}{2}}\Gamma(\frac{n}{2})}x^{\frac{n}{2}-1}e^{-\frac{x}{2}} & ;x > 0 \\ 0 & ;else\end{array}\right.\ ,\hspace{0.2cm} x\in\mathbb{R},\ n\in\mathbb{R}_{>0}\end{split}\]
\[\Gamma(x)=\int^{-\infty}_{0}t^{x-1}e^{-t}dt\]

Example:

"attr_1": ["c",2]
distribution_normal

Overview:

Value

Explanation

Identifier

c

Additional parameter

n

Degrees of freedom

Exceptions

InvalidFormat

List does not have length 2

InvalidType

n is not of type float or int

InvalidValue

n is less than or equal to zero


Student-t

The identifier t indicates a student-t distributed attribute. The second list entry determines the degrees of freedom n, which must be a positive floating-point or integer.

Distribution:

\[p_n(x)=\frac{\Gamma(\frac{n+1}{2})}{\Gamma(\frac{n}{2})\sqrt{n\pi}}(1+\frac{x^2}{n})^{-\frac{n+1}{2}}\ ,\hspace{0.2cm} x\in\mathbb{R},\ n\in\mathbb{R}_{>0}\]
\[\Gamma(x)=\int^{-\infty}_{0}t^{x-1}e^{-t}dt\]

Example:

"attr_1": ["t",4]
distribution_normal

Overview:

Value

Explanation

Identifier

t

Additional parameter

n

Degrees of freedom

Exceptions

InvalidFormat

List does not have length 2

InvalidType

n is not of type float or int

InvalidValue

n is less than or equal to zero