# Random¶

## xt::random::seed()¶

Set seed for random number generator. A common practice to get a ‘real’ random number is to use:

#include <ctime>

...

xt::random::seed(time(NULL));


## xt::random::gamma()¶

Produces (an array of) random positive floating-point values, distributed according to the probability density:

$P(x) = x^{\alpha-1} \frac{e^{-x / \beta}}{\beta^\alpha \; \Gamma(\alpha)}$

where $$\alpha$$ is the shape (also known as $$k$$) and $$\beta$$ the scale (also known as $$\theta$$), and $$\Gamma$$ is the Gamma function.

Note

Different from NumPy, the first argument is the shape of the output array.

## xt::random::weibull()¶

Produces (an array of) random positive floating-point values, distributed according to the probability density:

$P(x) = \frac{a}{b} \left( \frac{x}{b} \right)^{a - 1} e^{-(x / b)^a}$

where $$a > 0$$ is the shape parameter and $$b > 0$$ the scale parameter. In particular, a random variable is produced as

$X = b (- \ln (U))^{1/a}$

where $$U$$ is drawn from the uniform distribution (0, 1].

By default both the shape $$a = 1$$ and the scale $$b = 1$$. Note that you can specify only $$a$$ while choosing the default for $$b$$.

Note

Different from NumPy, the first argument is the shape of the output array.