File: random.rst

package info (click to toggle)
xtensor 0.25.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 6,476 kB
  • sloc: cpp: 65,302; makefile: 202; python: 171; javascript: 8
file content (128 lines) | stat: -rw-r--r-- 3,497 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
.. Copyright (c) 2016, Johan Mabille, Sylvain Corlay and Wolf Vollprecht

   Distributed under the terms of the BSD 3-Clause License.

   The full license is in the file LICENSE, distributed with this software.

.. _random:

******
Random
******

:cpp:func:`xt::random::seed`
============================

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

.. code-block:: cpp

    #include <ctime>

    ...

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

:cpp:func:`xt::random::rand`
============================

:cpp:func:`xt::random::randint`
===============================

:cpp:func:`xt::random::randn`
=============================

:cpp:func:`xt::random::binomial`
================================

:cpp:func:`xt::random::geometric`
=================================

:cpp:func:`xt::random::negative_binomial`
=========================================

:cpp:func:`xt::random::poisson`
===============================

:cpp:func:`xt::random::exponential`
===================================

:cpp:func:`xt::random::gamma`
=============================

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

.. math::

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

where :math:`\alpha` is the shape (also known as :math:`k`) and :math:`\beta` the scale
(also known as :math:`\theta`), and :math:`\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>`_

:cpp:func:`xt::random::weibull`
===============================

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

.. math::

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

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

.. math::

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

where :math:`U` is drawn from the uniform distribution (0, 1].

By default both the shape :math:`a = 1` and the scale :math:`b = 1`.
Note that you can specify only :math:`a` while choosing the default for :math:`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>`_

:cpp:func:`xt::random::extreme_value`
=====================================

:cpp:func:`xt::random::lognormal`
=================================

:cpp:func:`xt::random::cauchy`
==============================

:cpp:func:`xt::random::fisher_f`
================================

:cpp:func:`xt::random::student_t`
=================================

:cpp:func:`xt::random::choice`
==============================

:cpp:func:`xt::random::shuffle`
===============================

:cpp:func:`xt::random::permutation`
===================================