Skip to content

Latest commit

 

History

History
128 lines (80 loc) · 3.42 KB

random.rst

File metadata and controls

128 lines (80 loc) · 3.42 KB

Random

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));

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.

.. seealso::

    *   :any:`numpy.random.gamma`
    *   `std::gamma_distribution <https://en.cppreference.com/w/cpp/numeric/random/gamma_distribution>`_
    *   `Weisstein, Eric W. "Gamma Distribution." From MathWorld – A Wolfram Web Resource. <http://mathworld.wolfram.com/GammaDistribution.html>`_
    *   `Wikipedia, "Gamma distribution". <https://en.wikipedia.org/wiki/Gamma_distribution>`_

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.

.. seealso::

    *   :any:`numpy.random.weibull`
    *   `std::weibull_distribution <https://en.cppreference.com/w/cpp/numeric/random/weibull_distribution>`_
    *   `Wikipedia, "Weibull distribution". <https://en.wikipedia.org/wiki/Weibull_distribution>`_