forked from arrayfire/arrayfire-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharrayfire.random.html
More file actions
315 lines (267 loc) · 17.9 KB
/
arrayfire.random.html
File metadata and controls
315 lines (267 loc) · 17.9 KB
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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>arrayfire.random module — ArrayFire Python documentation</title>
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<link rel="stylesheet" href="_static/alabaster.css" type="text/css" />
<link rel="stylesheet" type="text/css" href="_static/graphviz.css" />
<link rel="stylesheet" href="_static/style.css" type="text/css" />
<script id="documentation_options" data-url_root="./" src="_static/documentation_options.js"></script>
<script src="_static/jquery.js"></script>
<script src="_static/underscore.js"></script>
<script src="_static/doctools.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="stylesheet" href="_static/custom.css" type="text/css" />
<meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />
</head><body>
<div class="document">
<div class="documentwrapper">
<div class="bodywrapper">
<div class="body" role="main">
<div class="section" id="module-arrayfire.random">
<span id="arrayfire-random-module"></span><h1>arrayfire.random module<a class="headerlink" href="#module-arrayfire.random" title="Permalink to this headline">¶</a></h1>
<p>Random engine class and functions to generate random numbers.</p>
<dl class="py class">
<dt id="arrayfire.random.Random_Engine">
<em class="property"><span class="pre">class</span> </em><code class="sig-prename descclassname"><span class="pre">arrayfire.random.</span></code><code class="sig-name descname"><span class="pre">Random_Engine</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="pre">engine_type=<RANDOM_ENGINE.PHILOX_4X32_10:</span> <span class="pre">100></span></em>, <em class="sig-param"><span class="pre">seed=0</span></em>, <em class="sig-param"><span class="pre">engine=None</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/arrayfire/random.html#Random_Engine"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#arrayfire.random.Random_Engine" title="Permalink to this definition">¶</a></dt>
<dd><p>Bases: <code class="xref py py-class docutils literal notranslate"><span class="pre">object</span></code></p>
<p>Class to handle random number generator engines.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>engine_type</strong><span class="classifier">optional: RANDOME_ENGINE. default: RANDOM_ENGINE.PHILOX</span></dt><dd><ul class="simple">
<li><p>Specifies the type of random engine to be created. Can be one of:</p></li>
<li><p>RANDOM_ENGINE.PHILOX_4X32_10</p></li>
<li><p>RANDOM_ENGINE.THREEFRY_2X32_16</p></li>
<li><p>RANDOM_ENGINE.MERSENNE_GP11213</p></li>
<li><p>RANDOM_ENGINE.PHILOX (same as RANDOM_ENGINE.PHILOX_4X32_10)</p></li>
<li><p>RANDOM_ENGINE.THREEFRY (same as RANDOM_ENGINE.THREEFRY_2X32_16)</p></li>
<li><p>RANDOM_ENGINE.DEFAULT</p></li>
<li><p>Not used if engine is not None</p></li>
</ul>
</dd>
<dt><strong>seed</strong><span class="classifier">optional int. default: 0</span></dt><dd><ul class="simple">
<li><p>Specifies the seed for the random engine</p></li>
<li><p>Not used if engine is not None</p></li>
</ul>
</dd>
<dt><strong>engine</strong><span class="classifier">optional ctypes.c_void_p. default: None.</span></dt><dd><ul class="simple">
<li><p>Used a handle created by the C api to create the Random_Engine.</p></li>
</ul>
</dd>
</dl>
</dd>
</dl>
<p class="rubric">Methods</p>
<table class="longtable docutils align-default">
<colgroup>
<col style="width: 10%" />
<col style="width: 90%" />
</colgroup>
<tbody>
<tr class="row-odd"><td><p><a class="reference internal" href="#arrayfire.random.Random_Engine.get_seed" title="arrayfire.random.Random_Engine.get_seed"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_seed</span></code></a>()</p></td>
<td><p>Get the seed for the random engine.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#arrayfire.random.Random_Engine.get_type" title="arrayfire.random.Random_Engine.get_type"><code class="xref py py-obj docutils literal notranslate"><span class="pre">get_type</span></code></a>()</p></td>
<td><p>Get the type of the random engine.</p></td>
</tr>
<tr class="row-odd"><td><p><a class="reference internal" href="#arrayfire.random.Random_Engine.set_seed" title="arrayfire.random.Random_Engine.set_seed"><code class="xref py py-obj docutils literal notranslate"><span class="pre">set_seed</span></code></a>(seed)</p></td>
<td><p>Set the seed for the random engine.</p></td>
</tr>
<tr class="row-even"><td><p><a class="reference internal" href="#arrayfire.random.Random_Engine.set_type" title="arrayfire.random.Random_Engine.set_type"><code class="xref py py-obj docutils literal notranslate"><span class="pre">set_type</span></code></a>(engine_type)</p></td>
<td><p>Set the type of the random engine.</p></td>
</tr>
</tbody>
</table>
<dl class="py method">
<dt id="arrayfire.random.Random_Engine.get_seed">
<code class="sig-name descname"><span class="pre">get_seed</span></code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/arrayfire/random.html#Random_Engine.get_seed"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#arrayfire.random.Random_Engine.get_seed" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the seed for the random engine.</p>
</dd></dl>
<dl class="py method">
<dt id="arrayfire.random.Random_Engine.get_type">
<code class="sig-name descname"><span class="pre">get_type</span></code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/arrayfire/random.html#Random_Engine.get_type"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#arrayfire.random.Random_Engine.get_type" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the type of the random engine.</p>
</dd></dl>
<dl class="py method">
<dt id="arrayfire.random.Random_Engine.set_seed">
<code class="sig-name descname"><span class="pre">set_seed</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">seed</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/arrayfire/random.html#Random_Engine.set_seed"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#arrayfire.random.Random_Engine.set_seed" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the seed for the random engine.</p>
</dd></dl>
<dl class="py method">
<dt id="arrayfire.random.Random_Engine.set_type">
<code class="sig-name descname"><span class="pre">set_type</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">engine_type</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/arrayfire/random.html#Random_Engine.set_type"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#arrayfire.random.Random_Engine.set_type" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the type of the random engine.</p>
</dd></dl>
</dd></dl>
<dl class="py function">
<dt id="arrayfire.random.get_default_random_engine">
<code class="sig-prename descclassname"><span class="pre">arrayfire.random.</span></code><code class="sig-name descname"><span class="pre">get_default_random_engine</span></code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/arrayfire/random.html#get_default_random_engine"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#arrayfire.random.get_default_random_engine" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the default random engine</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><dl class="simple">
<dt>The default random engine used by randu and randn</dt><dd></dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="arrayfire.random.get_seed">
<code class="sig-prename descclassname"><span class="pre">arrayfire.random.</span></code><code class="sig-name descname"><span class="pre">get_seed</span></code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="reference internal" href="_modules/arrayfire/random.html#get_seed"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#arrayfire.random.get_seed" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the seed for the random number generator.</p>
<dl class="field-list simple">
<dt class="field-odd">Returns</dt>
<dd class="field-odd"><dl class="simple">
<dt>seed: int.</dt><dd><p>Seed for the random number generator</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="arrayfire.random.randn">
<code class="sig-prename descclassname"><span class="pre">arrayfire.random.</span></code><code class="sig-name descname"><span class="pre">randn</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="pre">d0</span></em>, <em class="sig-param"><span class="pre">d1=None</span></em>, <em class="sig-param"><span class="pre">d2=None</span></em>, <em class="sig-param"><span class="pre">d3=None</span></em>, <em class="sig-param"><span class="pre">dtype=<Dtype.f32:</span> <span class="pre">0></span></em>, <em class="sig-param"><span class="pre">engine=None</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/arrayfire/random.html#randn"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#arrayfire.random.randn" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a multi dimensional array containing values from a normal distribution.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>d0</strong><span class="classifier">int.</span></dt><dd><p>Length of first dimension.</p>
</dd>
<dt><strong>d1</strong><span class="classifier">optional: int. default: None.</span></dt><dd><p>Length of second dimension.</p>
</dd>
<dt><strong>d2</strong><span class="classifier">optional: int. default: None.</span></dt><dd><p>Length of third dimension.</p>
</dd>
<dt><strong>d3</strong><span class="classifier">optional: int. default: None.</span></dt><dd><p>Length of fourth dimension.</p>
</dd>
<dt><strong>dtype</strong><span class="classifier">optional: af.Dtype. default: af.Dtype.f32.</span></dt><dd><p>Data type of the array.</p>
</dd>
<dt><strong>engine</strong><span class="classifier">optional: Random_Engine. default: None.</span></dt><dd><p>If engine is None, uses a default engine created by arrayfire.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt><strong>out</strong><span class="classifier">af.Array</span></dt><dd><p>Multi dimensional array whose elements are sampled from a normal distribution with mean 0 and sigma of 1.
- If d1 is None, <cite>out</cite> is 1D of size (d0,).
- If d1 is not None and d2 is None, <cite>out</cite> is 2D of size (d0, d1).
- If d1 and d2 are not None and d3 is None, <cite>out</cite> is 3D of size (d0, d1, d2).
- If d1, d2, d3 are all not None, <cite>out</cite> is 4D of size (d0, d1, d2, d3).</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="arrayfire.random.randu">
<code class="sig-prename descclassname"><span class="pre">arrayfire.random.</span></code><code class="sig-name descname"><span class="pre">randu</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="pre">d0</span></em>, <em class="sig-param"><span class="pre">d1=None</span></em>, <em class="sig-param"><span class="pre">d2=None</span></em>, <em class="sig-param"><span class="pre">d3=None</span></em>, <em class="sig-param"><span class="pre">dtype=<Dtype.f32:</span> <span class="pre">0></span></em>, <em class="sig-param"><span class="pre">engine=None</span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/arrayfire/random.html#randu"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#arrayfire.random.randu" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a multi dimensional array containing values from a uniform distribution.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>d0</strong><span class="classifier">int.</span></dt><dd><p>Length of first dimension.</p>
</dd>
<dt><strong>d1</strong><span class="classifier">optional: int. default: None.</span></dt><dd><p>Length of second dimension.</p>
</dd>
<dt><strong>d2</strong><span class="classifier">optional: int. default: None.</span></dt><dd><p>Length of third dimension.</p>
</dd>
<dt><strong>d3</strong><span class="classifier">optional: int. default: None.</span></dt><dd><p>Length of fourth dimension.</p>
</dd>
<dt><strong>dtype</strong><span class="classifier">optional: af.Dtype. default: af.Dtype.f32.</span></dt><dd><p>Data type of the array.</p>
</dd>
<dt><strong>engine</strong><span class="classifier">optional: Random_Engine. default: None.</span></dt><dd><p>If engine is None, uses a default engine created by arrayfire.</p>
</dd>
</dl>
</dd>
<dt class="field-even">Returns</dt>
<dd class="field-even"><dl class="simple">
<dt><strong>out</strong><span class="classifier">af.Array</span></dt><dd><p>Multi dimensional array whose elements are sampled uniformly between [0, 1].
- If d1 is None, <cite>out</cite> is 1D of size (d0,).
- If d1 is not None and d2 is None, <cite>out</cite> is 2D of size (d0, d1).
- If d1 and d2 are not None and d3 is None, <cite>out</cite> is 3D of size (d0, d1, d2).
- If d1, d2, d3 are all not None, <cite>out</cite> is 4D of size (d0, d1, d2, d3).</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="arrayfire.random.set_default_random_engine_type">
<code class="sig-prename descclassname"><span class="pre">arrayfire.random.</span></code><code class="sig-name descname"><span class="pre">set_default_random_engine_type</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">engine_type</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/arrayfire/random.html#set_default_random_engine_type"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#arrayfire.random.set_default_random_engine_type" title="Permalink to this definition">¶</a></dt>
<dd><p>Set random engine type for default random engine.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>engine_type</strong><span class="classifier">RANDOME_ENGINE.</span></dt><dd><ul class="simple">
<li><p>Specifies the type of random engine to be created. Can be one of:</p></li>
<li><p>RANDOM_ENGINE.PHILOX_4X32_10</p></li>
<li><p>RANDOM_ENGINE.THREEFRY_2X32_16</p></li>
<li><p>RANDOM_ENGINE.MERSENNE_GP11213</p></li>
<li><p>RANDOM_ENGINE.PHILOX (same as RANDOM_ENGINE.PHILOX_4X32_10)</p></li>
<li><p>RANDOM_ENGINE.THREEFRY (same as RANDOM_ENGINE.THREEFRY_2X32_16)</p></li>
<li><p>RANDOM_ENGINE.DEFAULT</p></li>
</ul>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
<dl class="py function">
<dt id="arrayfire.random.set_seed">
<code class="sig-prename descclassname"><span class="pre">arrayfire.random.</span></code><code class="sig-name descname"><span class="pre">set_seed</span></code><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">seed</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0</span></span></em><span class="sig-paren">)</span><a class="reference internal" href="_modules/arrayfire/random.html#set_seed"><span class="viewcode-link"><span class="pre">[source]</span></span></a><a class="headerlink" href="#arrayfire.random.set_seed" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the seed for the random number generator.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters</dt>
<dd class="field-odd"><dl class="simple">
<dt><strong>seed: int.</strong></dt><dd><p>Seed for the random number generator</p>
</dd>
</dl>
</dd>
</dl>
</dd></dl>
</div>
</div>
</div>
</div>
<div class="sphinxsidebar" role="navigation" aria-label="main navigation">
<div class="sphinxsidebarwrapper">
<p class="logo"><a href="index.html">
<img class="logo" src="_static/arrayfire_logo_symbol.png" alt="Logo"/>
</a></p>
<h1 class="logo"><a href="index.html">ArrayFire</a></h1>
<h3>Navigation</h3>
<div class="relations">
<h3>Related Topics</h3>
<ul>
<li><a href="index.html">Documentation overview</a><ul>
</ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
<h3 id="searchlabel">Quick search</h3>
<div class="searchformwrapper">
<form class="search" action="search.html" method="get">
<input type="text" name="q" aria-labelledby="searchlabel" />
<input type="submit" value="Go" />
</form>
</div>
</div>
<script>$('#searchbox').show(0);</script>
</div>
</div>
<div class="clearer"></div>
</div>
<div class="footer">
©2020, ArrayFire.
|
Powered by <a href="http://sphinx-doc.org/">Sphinx 3.5.1</a>
& <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.12</a>
|
<a href="_sources/arrayfire.random.rst.txt"
rel="nofollow">Page source</a>
</div>
</body>
</html>