File: Random-Number-Generation.html

package info (click to toggle)
octave 10.3.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 145,388 kB
  • sloc: cpp: 335,976; ansic: 82,241; fortran: 20,963; objc: 9,402; sh: 8,756; yacc: 4,392; lex: 4,333; perl: 1,544; java: 1,366; awk: 1,259; makefile: 660; xml: 192
file content (116 lines) | stat: -rw-r--r-- 8,171 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
<!DOCTYPE html>
<html>
<!-- Created by GNU Texinfo 7.1.1, https://www.gnu.org/software/texinfo/ -->
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Random Number Generation (GNU Octave (version 10.3.0))</title>

<meta name="description" content="Random Number Generation (GNU Octave (version 10.3.0))">
<meta name="keywords" content="Random Number Generation (GNU Octave (version 10.3.0))">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta name="viewport" content="width=device-width,initial-scale=1">

<link href="index.html" rel="start" title="Top">
<link href="Concept-Index.html" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Statistics.html" rel="up" title="Statistics">
<link href="Distributions.html" rel="prev" title="Distributions">
<style type="text/css">
<!--
a.copiable-link {visibility: hidden; text-decoration: none; line-height: 0em}
span:hover a.copiable-link {visibility: visible}
strong.def-name {font-family: monospace; font-weight: bold; font-size: larger}
-->
</style>
<link rel="stylesheet" type="text/css" href="octave.css">


</head>

<body lang="en">
<div class="section-level-extent" id="Random-Number-Generation">
<div class="nav-panel">
<p>
Previous: <a href="Distributions.html" accesskey="p" rel="prev">Distributions</a>, Up: <a href="Statistics.html" accesskey="u" rel="up">Statistics</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<h3 class="section" id="Random-Number-Generation-1"><span>26.6 Random Number Generation<a class="copiable-link" href="#Random-Number-Generation-1"> &para;</a></span></h3>

<p>Octave can generate random numbers from a large number of distributions.  The
random number generators are based on the random number generators described in
<a class="ref" href="Special-Utility-Matrices.html">Special Utility Matrices</a>.
</p>
<p>The following table summarizes the available random number generators (in
alphabetical order).
</p>
<table class="multitable">
<thead><tr><th width="40%">Distribution</th><th width="30%">Function</th></tr></thead>
<tbody><tr><td width="40%">Univariate Discrete Distribution</td><td width="30%"><code class="code">discrete_rnd</code></td></tr>
<tr><td width="40%">Empirical Distribution</td><td width="30%"><code class="code">empirical_rnd</code></td></tr>
<tr><td width="40%">Exponential Distribution</td><td width="30%"><code class="code">rande</code></td></tr>
<tr><td width="40%">Gamma Distribution</td><td width="30%"><code class="code">randg</code></td></tr>
<tr><td width="40%">Poisson Distribution</td><td width="30%"><code class="code">randp</code></td></tr>
<tr><td width="40%">Standard Normal Distribution</td><td width="30%"><code class="code">randn</code></td></tr>
<tr><td width="40%">Uniform Distribution</td><td width="30%"><code class="code">rand</code></td></tr>
<tr><td width="40%">Uniform Distribution (integers)</td><td width="30%"><code class="code">randi</code></td></tr>
</tbody>
</table>

<a class="anchor" id="XREFdiscrete_005frnd"></a><span style="display:block; margin-top:-4.5ex;">&nbsp;</span>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-discrete_005frnd"><span><code class="def-type"><var class="var">rnd</var> =</code> <strong class="def-name">discrete_rnd</strong> <code class="def-code-arguments">(<var class="var">v</var>, <var class="var">p</var>)</code><a class="copiable-link" href="#index-discrete_005frnd"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-discrete_005frnd-1"><span><code class="def-type"><var class="var">rnd</var> =</code> <strong class="def-name">discrete_rnd</strong> <code class="def-code-arguments">(<var class="var">v</var>, <var class="var">p</var>, <var class="var">r</var>)</code><a class="copiable-link" href="#index-discrete_005frnd-1"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-discrete_005frnd-2"><span><code class="def-type"><var class="var">rnd</var> =</code> <strong class="def-name">discrete_rnd</strong> <code class="def-code-arguments">(<var class="var">v</var>, <var class="var">p</var>, <var class="var">r</var>, <var class="var">c</var>, &hellip;)</code><a class="copiable-link" href="#index-discrete_005frnd-2"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-discrete_005frnd-3"><span><code class="def-type"><var class="var">rnd</var> =</code> <strong class="def-name">discrete_rnd</strong> <code class="def-code-arguments">(<var class="var">v</var>, <var class="var">p</var>, [<var class="var">sz</var>])</code><a class="copiable-link" href="#index-discrete_005frnd-3"> &para;</a></span></dt>
<dd><p>Return a matrix of random samples from the univariate distribution which
assumes the values in <var class="var">v</var> with probabilities <var class="var">p</var>.
</p>
<p>When called with a single size argument, return a square matrix with
the dimension specified.  When called with more than one scalar argument the
first two arguments are taken as the number of rows and columns and any
further arguments specify additional matrix dimensions.  The size may also
be specified with a vector of dimensions <var class="var">sz</var>.
</p>
<p>If no size arguments are given then the result matrix is the common size of
<var class="var">v</var> and <var class="var">p</var>.
</p></dd></dl>


<a class="anchor" id="XREFempirical_005frnd"></a><span style="display:block; margin-top:-4.5ex;">&nbsp;</span>


<dl class="first-deftypefn">
<dt class="deftypefn" id="index-empirical_005frnd"><span><code class="def-type"><var class="var">rnd</var> =</code> <strong class="def-name">empirical_rnd</strong> <code class="def-code-arguments">(<var class="var">data</var>)</code><a class="copiable-link" href="#index-empirical_005frnd"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-empirical_005frnd-1"><span><code class="def-type"><var class="var">rnd</var> =</code> <strong class="def-name">empirical_rnd</strong> <code class="def-code-arguments">(<var class="var">data</var>, <var class="var">r</var>)</code><a class="copiable-link" href="#index-empirical_005frnd-1"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-empirical_005frnd-2"><span><code class="def-type"><var class="var">rnd</var> =</code> <strong class="def-name">empirical_rnd</strong> <code class="def-code-arguments">(<var class="var">data</var>, <var class="var">r</var>, <var class="var">c</var>, &hellip;)</code><a class="copiable-link" href="#index-empirical_005frnd-2"> &para;</a></span></dt>
<dt class="deftypefnx def-cmd-deftypefn" id="index-empirical_005frnd-3"><span><code class="def-type"><var class="var">rnd</var> =</code> <strong class="def-name">empirical_rnd</strong> <code class="def-code-arguments">(<var class="var">data</var>, [<var class="var">sz</var>])</code><a class="copiable-link" href="#index-empirical_005frnd-3"> &para;</a></span></dt>
<dd><p>Return a matrix of random samples from the empirical distribution obtained
from the univariate sample <var class="var">data</var>.
</p>
<p>When called with a single size argument, return a square matrix with
the dimension specified.  When called with more than one scalar argument the
first two arguments are taken as the number of rows and columns and any
further arguments specify additional matrix dimensions.  The size may also
be specified with a vector of dimensions <var class="var">sz</var>.
</p>
<p>If no size arguments are given then the result matrix is a random ordering
of the sample <var class="var">data</var>.
</p></dd></dl>



</div>
<hr>
<div class="nav-panel">
<p>
Previous: <a href="Distributions.html">Distributions</a>, Up: <a href="Statistics.html">Statistics</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html" title="Index" rel="index">Index</a>]</p>
</div>



</body>
</html>