blob: 378726d3f8a0c0c4986fdc62f36efdcf31859bf4 [file] [log] [blame]
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta content="IE=edge" http-equiv="X-UA-Compatible"/>
<meta content="width=device-width, initial-scale=1" name="viewport"/>
<title>Random Distribution Generator NDArray API — mxnet documentation</title>
<link crossorigin="anonymous" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" rel="stylesheet"/>
<link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet"/>
<link href="../../../_static/basic.css" rel="stylesheet" type="text/css"/>
<link href="../../../_static/pygments.css" rel="stylesheet" type="text/css"/>
<link href="../../../_static/mxnet.css" rel="stylesheet" type="text/css">
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../../../',
VERSION: '',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true,
SOURCELINK_SUFFIX: ''
};
</script>
<script src="../../../_static/jquery-1.11.1.js" type="text/javascript"></script>
<script src="../../../_static/underscore.js" type="text/javascript"></script>
<script src="../../../_static/searchtools_custom.js" type="text/javascript"></script>
<script src="../../../_static/doctools.js" type="text/javascript"></script>
<script src="../../../_static/selectlang.js" type="text/javascript"></script>
<script src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML" type="text/javascript"></script>
<script type="text/javascript"> jQuery(function() { Search.loadIndex("/searchindex.js"); Search.init();}); </script>
<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new
Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', 'UA-96378503-1', 'auto');
ga('send', 'pageview');
</script>
<!-- -->
<!-- <script type="text/javascript" src="../../../_static/jquery.js"></script> -->
<!-- -->
<!-- <script type="text/javascript" src="../../../_static/underscore.js"></script> -->
<!-- -->
<!-- <script type="text/javascript" src="../../../_static/doctools.js"></script> -->
<!-- -->
<!-- <script type="text/javascript" src="https://cdn.mathjax.org/mathjax/latest/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script> -->
<!-- -->
<link href="../index.html" rel="up" title="MXNet - Python API"/>
<link href="linalg.html" rel="next" title="Linear Algebra NDArray API">
<link href="ndarray.html" rel="prev" title="NDArray API">
<link href="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/mxnet-icon.png" rel="icon" type="image/png"/>
</link></link></link></head>
<body background="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/mxnet-background-compressed.jpeg" role="document">
<div class="content-block"><div class="navbar navbar-fixed-top">
<div class="container" id="navContainer">
<div class="innder" id="header-inner">
<h1 id="logo-wrap">
<a href="../../../" id="logo"><img src="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/mxnet_logo.png"/></a>
</h1>
<nav class="nav-bar" id="main-nav">
<a class="main-nav-link" href="../../../install/index.html">Install</a>
<a class="main-nav-link" href="../../../tutorials/index.html">Tutorials</a>
<span id="dropdown-menu-position-anchor">
<a aria-expanded="true" aria-haspopup="true" class="main-nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button">Gluon <span class="caret"></span></a>
<ul class="dropdown-menu navbar-menu" id="package-dropdown-menu">
<li><a class="main-nav-link" href="../../../gluon/index.html">About</a></li>
<li><a class="main-nav-link" href="http://gluon.mxnet.io">Tutorials</a></li>
</ul>
</span>
<span id="dropdown-menu-position-anchor">
<a aria-expanded="true" aria-haspopup="true" class="main-nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button">API <span class="caret"></span></a>
<ul class="dropdown-menu navbar-menu" id="package-dropdown-menu">
<li><a class="main-nav-link" href="../../../api/python/index.html">Python</a></li>
<li><a class="main-nav-link" href="../../../api/scala/index.html">Scala</a></li>
<li><a class="main-nav-link" href="../../../api/r/index.html">R</a></li>
<li><a class="main-nav-link" href="../../../api/julia/index.html">Julia</a></li>
<li><a class="main-nav-link" href="../../../api/c++/index.html">C++</a></li>
<li><a class="main-nav-link" href="../../../api/perl/index.html">Perl</a></li>
</ul>
</span>
<span id="dropdown-menu-position-anchor-docs">
<a aria-expanded="true" aria-haspopup="true" class="main-nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button">Docs <span class="caret"></span></a>
<ul class="dropdown-menu navbar-menu" id="package-dropdown-menu-docs">
<li><a class="main-nav-link" href="../../../faq/index.html">FAQ</a></li>
<li><a class="main-nav-link" href="../../../architecture/index.html">Architecture</a></li>
<li><a class="main-nav-link" href="https://github.com/apache/incubator-mxnet/tree/0.12.1/example">Examples</a></li>
<li><a class="main-nav-link" href="../../../model_zoo/index.html">Model Zoo</a></li>
</ul>
</span>
<a class="main-nav-link" href="https://github.com/dmlc/mxnet">Github</a>
<span id="dropdown-menu-position-anchor-community">
<a aria-expanded="true" aria-haspopup="true" class="main-nav-link dropdown-toggle" data-toggle="dropdown" href="#" role="button">Community <span class="caret"></span></a>
<ul class="dropdown-menu navbar-menu" id="package-dropdown-menu-community">
<li><a class="main-nav-link" href="../../../community/index.html">Community</a></li>
<li><a class="main-nav-link" href="../../../community/contribute.html">Contribute</a></li>
<li><a class="main-nav-link" href="../../../community/powered_by.html">Powered By</a></li>
</ul>
</span>
<a class="main-nav-link" href="http://discuss.mxnet.io">Discuss</a>
<span id="dropdown-menu-position-anchor-version" style="position: relative"><a href="#" class="main-nav-link dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="true">Versions(0.12.1)<span class="caret"></span></a><ul id="package-dropdown-menu" class="dropdown-menu"><li><a class="main-nav-link" href=https://mxnet.incubator.apache.org/>1.0.0</a></li><li><a class="main-nav-link" href=https://mxnet.incubator.apache.org/versions/0.12.1/index.html>0.12.1</a></li><li><a class="main-nav-link" href=https://mxnet.incubator.apache.org/versions/0.12.0/index.html>0.12.0</a></li><li><a class="main-nav-link" href=https://mxnet.incubator.apache.org/versions/0.11.0/index.html>0.11.0</a></li><li><a class="main-nav-link" href=https://mxnet.incubator.apache.org/versions/master/index.html>master</a></li></ul></span></nav>
<script> function getRootPath(){ return "../../../" } </script>
<div class="burgerIcon dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button"></a>
<ul class="dropdown-menu" id="burgerMenu">
<li><a href="../../../install/index.html">Install</a></li>
<li><a class="main-nav-link" href="../../../tutorials/index.html">Tutorials</a></li>
<li class="dropdown-submenu">
<a href="#" tabindex="-1">Community</a>
<ul class="dropdown-menu">
<li><a href="../../../community/index.html" tabindex="-1">Community</a></li>
<li><a href="../../../community/contribute.html" tabindex="-1">Contribute</a></li>
<li><a href="../../../community/powered_by.html" tabindex="-1">Powered By</a></li>
</ul>
</li>
<li class="dropdown-submenu">
<a href="#" tabindex="-1">API</a>
<ul class="dropdown-menu">
<li><a href="../../../api/python/index.html" tabindex="-1">Python</a>
</li>
<li><a href="../../../api/scala/index.html" tabindex="-1">Scala</a>
</li>
<li><a href="../../../api/r/index.html" tabindex="-1">R</a>
</li>
<li><a href="../../../api/julia/index.html" tabindex="-1">Julia</a>
</li>
<li><a href="../../../api/c++/index.html" tabindex="-1">C++</a>
</li>
<li><a href="../../../api/perl/index.html" tabindex="-1">Perl</a>
</li>
</ul>
</li>
<li class="dropdown-submenu">
<a href="#" tabindex="-1">Docs</a>
<ul class="dropdown-menu">
<li><a href="../../../tutorials/index.html" tabindex="-1">Tutorials</a></li>
<li><a href="../../../faq/index.html" tabindex="-1">FAQ</a></li>
<li><a href="../../../architecture/index.html" tabindex="-1">Architecture</a></li>
<li><a href="https://github.com/apache/incubator-mxnet/tree/0.12.1/example" tabindex="-1">Examples</a></li>
<li><a href="../../../model_zoo/index.html" tabindex="-1">Model Zoo</a></li>
</ul>
</li>
<li><a href="../../../architecture/index.html">Architecture</a></li>
<li><a class="main-nav-link" href="https://github.com/dmlc/mxnet">Github</a></li>
<li id="dropdown-menu-position-anchor-version-mobile" class="dropdown-submenu" style="position: relative"><a href="#" tabindex="-1">Versions(0.12.1)</a><ul class="dropdown-menu"><li><a tabindex="-1" href=https://mxnet.incubator.apache.org/>1.0.0</a></li><li><a tabindex="-1" href=https://mxnet.incubator.apache.org/versions/0.12.1/index.html>0.12.1</a></li><li><a tabindex="-1" href=https://mxnet.incubator.apache.org/versions/0.12.0/index.html>0.12.0</a></li><li><a tabindex="-1" href=https://mxnet.incubator.apache.org/versions/0.11.0/index.html>0.11.0</a></li><li><a tabindex="-1" href=https://mxnet.incubator.apache.org/versions/master/index.html>master</a></li></ul></li></ul>
</div>
<div class="plusIcon dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" role="button"><span aria-hidden="true" class="glyphicon glyphicon-plus"></span></a>
<ul class="dropdown-menu dropdown-menu-right" id="plusMenu"></ul>
</div>
<div id="search-input-wrap">
<form action="../../../search.html" autocomplete="off" class="" method="get" role="search">
<div class="form-group inner-addon left-addon">
<i class="glyphicon glyphicon-search"></i>
<input class="form-control" name="q" placeholder="Search" type="text"/>
</div>
<input name="check_keywords" type="hidden" value="yes"/>
<input name="area" type="hidden" value="default">
</input></form>
<div id="search-preview"></div>
</div>
<div id="searchIcon">
<span aria-hidden="true" class="glyphicon glyphicon-search"></span>
</div>
<!-- <div id="lang-select-wrap"> -->
<!-- <label id="lang-select-label"> -->
<!-- <\!-- <i class="fa fa-globe"></i> -\-> -->
<!-- <span></span> -->
<!-- </label> -->
<!-- <select id="lang-select"> -->
<!-- <option value="en">Eng</option> -->
<!-- <option value="zh">中文</option> -->
<!-- </select> -->
<!-- </div> -->
<!-- <a id="mobile-nav-toggle">
<span class="mobile-nav-toggle-bar"></span>
<span class="mobile-nav-toggle-bar"></span>
<span class="mobile-nav-toggle-bar"></span>
</a> -->
</div>
</div>
</div>
<script type="text/javascript">
$('body').css('background', 'white');
</script>
<div class="container">
<div class="row">
<div aria-label="main navigation" class="sphinxsidebar leftsidebar" role="navigation">
<div class="sphinxsidebarwrapper">
<ul class="current">
<li class="toctree-l1 current"><a class="reference internal" href="../index.html">Python Documents</a><ul class="current">
<li class="toctree-l2 current"><a class="reference internal" href="../index.html#ndarray-api">NDArray API</a><ul class="current">
<li class="toctree-l3"><a class="reference internal" href="ndarray.html">NDArray API</a></li>
<li class="toctree-l3 current"><a class="current reference internal" href="">Random Distribution Generator NDArray API</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#overview">Overview</a></li>
<li class="toctree-l4"><a class="reference internal" href="#random-distribution-generator">Random Distribution Generator</a></li>
<li class="toctree-l4"><a class="reference internal" href="#api-reference">API Reference</a></li>
</ul>
</li>
<li class="toctree-l3"><a class="reference internal" href="linalg.html">Linear Algebra NDArray API</a></li>
<li class="toctree-l3"><a class="reference internal" href="sparse.html">Sparse NDArray API</a></li>
<li class="toctree-l3"><a class="reference internal" href="contrib.html">Contrib NDArray API</a></li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="../index.html#symbol-api">Symbol API</a></li>
<li class="toctree-l2"><a class="reference internal" href="../index.html#module-api">Module API</a></li>
<li class="toctree-l2"><a class="reference internal" href="../index.html#autograd-api">Autograd API</a></li>
<li class="toctree-l2"><a class="reference internal" href="../index.html#gluon-api">Gluon API</a></li>
<li class="toctree-l2"><a class="reference internal" href="../index.html#kvstore-api">KVStore API</a></li>
<li class="toctree-l2"><a class="reference internal" href="../index.html#io-api">IO API</a></li>
<li class="toctree-l2"><a class="reference internal" href="../index.html#image-api">Image API</a></li>
<li class="toctree-l2"><a class="reference internal" href="../index.html#optimization-api">Optimization API</a></li>
<li class="toctree-l2"><a class="reference internal" href="../index.html#callback-api">Callback API</a></li>
<li class="toctree-l2"><a class="reference internal" href="../index.html#metric-api">Metric API</a></li>
<li class="toctree-l2"><a class="reference internal" href="../index.html#run-time-compilation-api">Run-Time Compilation API</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="../../r/index.html">R Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../julia/index.html">Julia Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../c++/index.html">C++ Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../scala/index.html">Scala Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../perl/index.html">Perl Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../faq/index.html">HowTo Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../architecture/index.html">System Documents</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../tutorials/index.html">Tutorials</a></li>
<li class="toctree-l1"><a class="reference internal" href="../../../community/index.html">Community</a></li>
</ul>
</div>
</div>
<div class="content">
<div class="page-tracker"></div>
<div class="section" id="random-distribution-generator-ndarray-api">
<span id="random-distribution-generator-ndarray-api"></span><h1>Random Distribution Generator NDArray API<a class="headerlink" href="#random-distribution-generator-ndarray-api" title="Permalink to this headline"></a></h1>
<div class="section" id="overview">
<span id="overview"></span><h2>Overview<a class="headerlink" href="#overview" title="Permalink to this headline"></a></h2>
<p>This document lists the random distribution generator routines of the <em>n</em>-dimensional array package:</p>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%"/>
<col width="90%"/>
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#module-mxnet.ndarray.random" title="mxnet.ndarray.random"><code class="xref py py-obj docutils literal"><span class="pre">mxnet.ndarray.random</span></code></a></td>
<td>Random distribution generator NDArray API of MXNet.</td>
</tr>
</tbody>
</table>
<p>The <code class="docutils literal"><span class="pre">Random</span> <span class="pre">Distribution</span> <span class="pre">Generator</span> <span class="pre">NDArray</span></code> API, defined in the <code class="docutils literal"><span class="pre">ndarray.random</span></code> package, provides
imperative random distribution generator operations on CPU/GPU.</p>
<p>In the rest of this document, we list routines provided by the <code class="docutils literal"><span class="pre">ndarray.random</span></code> package.</p>
</div>
<div class="section" id="random-distribution-generator">
<span id="random-distribution-generator"></span><h2>Random Distribution Generator<a class="headerlink" href="#random-distribution-generator" title="Permalink to this headline"></a></h2>
<table border="1" class="longtable docutils">
<colgroup>
<col width="10%"/>
<col width="90%"/>
</colgroup>
<tbody valign="top">
<tr class="row-odd"><td><a class="reference internal" href="#mxnet.ndarray.random.exponential" title="mxnet.ndarray.random.exponential"><code class="xref py py-obj docutils literal"><span class="pre">exponential</span></code></a></td>
<td>Draw samples from an exponential distribution.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#mxnet.ndarray.random.gamma" title="mxnet.ndarray.random.gamma"><code class="xref py py-obj docutils literal"><span class="pre">gamma</span></code></a></td>
<td>Draw random samples from a gamma distribution.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#mxnet.ndarray.random.generalized_negative_binomial" title="mxnet.ndarray.random.generalized_negative_binomial"><code class="xref py py-obj docutils literal"><span class="pre">generalized_negative_binomial</span></code></a></td>
<td>Draw random samples from a generalized negative binomial distribution.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#mxnet.ndarray.random.negative_binomial" title="mxnet.ndarray.random.negative_binomial"><code class="xref py py-obj docutils literal"><span class="pre">negative_binomial</span></code></a></td>
<td>Draw random samples from a negative binomial distribution.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#mxnet.ndarray.random.normal" title="mxnet.ndarray.random.normal"><code class="xref py py-obj docutils literal"><span class="pre">normal</span></code></a></td>
<td>Draw random samples from a normal (Gaussian) distribution.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="#mxnet.ndarray.random.poisson" title="mxnet.ndarray.random.poisson"><code class="xref py py-obj docutils literal"><span class="pre">poisson</span></code></a></td>
<td>Draw random samples from a Poisson distribution.</td>
</tr>
<tr class="row-odd"><td><a class="reference internal" href="#mxnet.ndarray.random.uniform" title="mxnet.ndarray.random.uniform"><code class="xref py py-obj docutils literal"><span class="pre">uniform</span></code></a></td>
<td>Draw random samples from a uniform distribution.</td>
</tr>
<tr class="row-even"><td><a class="reference internal" href="../symbol/random.html#mxnet.random.seed" title="mxnet.random.seed"><code class="xref py py-obj docutils literal"><span class="pre">mxnet.random.seed</span></code></a></td>
<td>Seeds the random number generators in MXNet.</td>
</tr>
</tbody>
</table>
</div>
<div class="section" id="api-reference">
<span id="api-reference"></span><h2>API Reference<a class="headerlink" href="#api-reference" title="Permalink to this headline"></a></h2>
<script src="../../../_static/js/auto_module_index.js" type="text/javascript"></script><span class="target" id="module-mxnet.ndarray.random"></span><p>Random distribution generator NDArray API of MXNet.</p>
<dl class="function">
<dt id="mxnet.ndarray.random.uniform">
<code class="descclassname">mxnet.ndarray.random.</code><code class="descname">uniform</code><span class="sig-paren">(</span><em>low=0</em>, <em>high=1</em>, <em>shape=_Null</em>, <em>dtype=_Null</em>, <em>ctx=None</em>, <em>out=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.ndarray.random.uniform" title="Permalink to this definition"></a></dt>
<dd><p>Draw random samples from a uniform distribution.</p>
<p>Samples are uniformly distributed over the half-open interval <em>[low, high)</em>
(includes <em>low</em>, but excludes <em>high</em>).</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>low</strong> (<em>float or NDArray</em>) – Lower boundary of the output interval. All values generated will be
greater than or equal to low. The default value is 0.</li>
<li><strong>high</strong> (<em>float or NDArray</em>) – Upper boundary of the output interval. All values generated will be
less than high. The default value is 1.0.</li>
<li><strong>shape</strong> (<em>int or tuple of ints</em>) – The number of samples to draw. If shape is, e.g., <cite>(m, n)</cite> and <cite>low</cite> and
<cite>high</cite> are scalars, output shape will be <cite>(m, n)</cite>. If <cite>low</cite> and <cite>high</cite>
are NDArrays with shape, e.g., <cite>(x, y)</cite>, then output will have shape
<cite>(x, y, m, n)</cite>, where <cite>m*n</cite> samples are drawn for each <cite>[low, high)</cite> pair.</li>
<li><strong>dtype</strong> (<em>{'float16','float32', 'float64'}</em>) – Data type of output samples. Default is ‘float32’</li>
<li><strong>ctx</strong> (<em>Context</em>) – Device context of output. Default is current context. Overridden by
<cite>low.context</cite> when <cite>low</cite> is an NDArray.</li>
<li><strong>out</strong> (<a class="reference internal" href="ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray"><em>NDArray</em></a>) – Store output to an existing NDArray.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Examples</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">uniform</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">[ 0.54881352]</span>
<span class="go"><ndarray 1="" @cpu(0)<="" span="">
<span class="go">>>>> mx.nd.random.uniform(0, 1, ctx=mx.gpu(0))</span>
<span class="go">[ 0.92514056]</span>
<span class="go"><ndarray 1="" @gpu(0)=""></ndarray></span>
<span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">uniform</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">shape</span><span class="o">=</span><span class="p">(</span><span class="mi">2</span><span class="p">,))</span>
<span class="go">[[ 0.71589124 0.08976638]</span>
<span class="go"> [ 0.69450343 -0.15269041]]</span>
<span class="go"><ndarray 2x2="" @cpu(0)=""></ndarray></span>
<span class="gp">>>> </span><span class="n">low</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">])</span>
<span class="gp">>>> </span><span class="n">high</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">])</span>
<span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">uniform</span><span class="p">(</span><span class="n">low</span><span class="p">,</span> <span class="n">high</span><span class="p">,</span> <span class="n">shape</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="go">[[ 1.78653979 1.93707538]</span>
<span class="go"> [ 2.01311183 2.37081361]</span>
<span class="go"> [ 3.30491424 3.69977832]]</span>
<span class="go"><ndarray 3x2="" @cpu(0)=""></ndarray></span>
</ndarray></span></pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="mxnet.ndarray.random.normal">
<code class="descclassname">mxnet.ndarray.random.</code><code class="descname">normal</code><span class="sig-paren">(</span><em>loc=0</em>, <em>scale=1</em>, <em>shape=_Null</em>, <em>dtype=_Null</em>, <em>ctx=None</em>, <em>out=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.ndarray.random.normal" title="Permalink to this definition"></a></dt>
<dd><p>Draw random samples from a normal (Gaussian) distribution.</p>
<p>Samples are distributed according to a normal distribution parametrized
by <em>loc</em> (mean) and <em>scale</em> (standard deviation).</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>loc</strong> (<em>float or NDArray</em>) – Mean (centre) of the distribution.</li>
<li><strong>scale</strong> (<em>float or NDArray</em>) – Standard deviation (spread or width) of the distribution.</li>
<li><strong>shape</strong> (<em>int or tuple of ints</em>) – The number of samples to draw. If shape is, e.g., <cite>(m, n)</cite> and <cite>loc</cite> and
<cite>scale</cite> are scalars, output shape will be <cite>(m, n)</cite>. If <cite>loc</cite> and <cite>scale</cite>
are NDArrays with shape, e.g., <cite>(x, y)</cite>, then output will have shape
<cite>(x, y, m, n)</cite>, where <cite>m*n</cite> samples are drawn for each <cite>[loc, scale)</cite> pair.</li>
<li><strong>dtype</strong> (<em>{'float16','float32', 'float64'}</em>) – Data type of output samples. Default is ‘float32’</li>
<li><strong>ctx</strong> (<em>Context</em>) – Device context of output. Default is current context. Overridden by
<cite>loc.context</cite> when <cite>loc</cite> is an NDArray.</li>
<li><strong>out</strong> (<a class="reference internal" href="ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray"><em>NDArray</em></a>) – Store output to an existing NDArray.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Examples</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">normal</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">[ 2.21220636]</span>
<span class="go"><ndarray 1="" @cpu(0)=""></ndarray></span>
<span class="go">>>>> mx.nd.random.normal(0, 1, ctx=mx.gpu(0))</span>
<span class="go">[ 0.29253659]</span>
<span class="go"><ndarray 1="" @gpu(0)=""></ndarray></span>
<span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">normal</span><span class="p">(</span><span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">shape</span><span class="o">=</span><span class="p">(</span><span class="mi">2</span><span class="p">,))</span>
<span class="go">[-0.2259962 -0.51619542]</span>
<span class="go"><ndarray 2="" @cpu(0)=""></ndarray></span>
<span class="gp">>>> </span><span class="n">loc</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">])</span>
<span class="gp">>>> </span><span class="n">scale</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">])</span>
<span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">normal</span><span class="p">(</span><span class="n">loc</span><span class="p">,</span> <span class="n">scale</span><span class="p">,</span> <span class="n">shape</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="go">[[ 0.55912292 3.19566321]</span>
<span class="go"> [ 1.91728961 2.47706747]</span>
<span class="go"> [ 2.79666662 5.44254589]]</span>
<span class="go"><ndarray 3x2="" @cpu(0)=""></ndarray></span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="mxnet.ndarray.random.poisson">
<code class="descclassname">mxnet.ndarray.random.</code><code class="descname">poisson</code><span class="sig-paren">(</span><em>lam=1</em>, <em>shape=_Null</em>, <em>dtype=_Null</em>, <em>ctx=None</em>, <em>out=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.ndarray.random.poisson" title="Permalink to this definition"></a></dt>
<dd><p>Draw random samples from a Poisson distribution.</p>
<p>Samples are distributed according to a Poisson distribution parametrized
by <em>lambda</em> (rate). Samples will always be returned as a floating point data type.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>lam</strong> (<em>float or NDArray</em>) – Expectation of interval, should be >= 0.</li>
<li><strong>shape</strong> (<em>int or tuple of ints</em>) – The number of samples to draw. If shape is, e.g., <cite>(m, n)</cite> and <cite>lam</cite> is
a scalar, output shape will be <cite>(m, n)</cite>. If <cite>lam</cite>
is an NDArray with shape, e.g., <cite>(x, y)</cite>, then output will have shape
<cite>(x, y, m, n)</cite>, where <cite>m*n</cite> samples are drawn for each entry in <cite>lam</cite>.</li>
<li><strong>dtype</strong> (<em>{'float16','float32', 'float64'}</em>) – Data type of output samples. Default is ‘float32’</li>
<li><strong>ctx</strong> (<em>Context</em>) – Device context of output. Default is current context. Overridden by
<cite>lam.context</cite> when <cite>lam</cite> is an NDArray.</li>
<li><strong>out</strong> (<a class="reference internal" href="ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray"><em>NDArray</em></a>) – Store output to an existing NDArray.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Examples</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">poisson</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="go">[ 1.]</span>
<span class="go"><ndarray 1="" @cpu(0)=""></ndarray></span>
<span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">poisson</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">shape</span><span class="o">=</span><span class="p">(</span><span class="mi">2</span><span class="p">,))</span>
<span class="go">[ 0. 2.]</span>
<span class="go"><ndarray 2="" @cpu(0)=""></ndarray></span>
<span class="gp">>>> </span><span class="n">lam</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">])</span>
<span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">poisson</span><span class="p">(</span><span class="n">lam</span><span class="p">,</span> <span class="n">shape</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="go">[[ 1. 3.]</span>
<span class="go"> [ 3. 2.]</span>
<span class="go"> [ 2. 3.]]</span>
<span class="go"><ndarray 3x2="" @cpu(0)=""></ndarray></span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="mxnet.ndarray.random.exponential">
<code class="descclassname">mxnet.ndarray.random.</code><code class="descname">exponential</code><span class="sig-paren">(</span><em>scale=1</em>, <em>shape=_Null</em>, <em>dtype=_Null</em>, <em>ctx=None</em>, <em>out=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.ndarray.random.exponential" title="Permalink to this definition"></a></dt>
<dd><p>Draw samples from an exponential distribution.</p>
<p>Its probability density function is</p>
<blockquote>
<div>f(x; frac{1}{beta}) = frac{1}{beta} exp(-frac{x}{beta}),</div></blockquote>
<p>for x > 0 and 0 elsewhere. beta is the scale parameter, which is the
inverse of the rate parameter lambda = 1/beta.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>scale</strong> (<em>float or NDArray</em>) – The scale parameter, beta = 1/lambda.</li>
<li><strong>shape</strong> (<em>int or tuple of ints</em>) – The number of samples to draw. If shape is, e.g., <cite>(m, n)</cite> and <cite>scale</cite> is
a scalar, output shape will be <cite>(m, n)</cite>. If <cite>scale</cite>
is an NDArray with shape, e.g., <cite>(x, y)</cite>, then output will have shape
<cite>(x, y, m, n)</cite>, where <cite>m*n</cite> samples are drawn for each entry in <cite>scale</cite>.</li>
<li><strong>dtype</strong> (<em>{'float16','float32', 'float64'}</em>) – Data type of output samples. Default is ‘float32’</li>
<li><strong>ctx</strong> (<em>Context</em>) – Device context of output. Default is current context. Overridden by
<cite>scale.context</cite> when <cite>scale</cite> is an NDArray.</li>
<li><strong>out</strong> (<a class="reference internal" href="ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray"><em>NDArray</em></a>) – Store output to an existing NDArray.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Examples</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">exponential</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>
<span class="go">[ 0.79587454]</span>
<span class="go"><ndarray 1="" @cpu(0)=""></ndarray></span>
<span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">exponential</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">shape</span><span class="o">=</span><span class="p">(</span><span class="mi">2</span><span class="p">,))</span>
<span class="go">[ 0.89856035 1.25593066]</span>
<span class="go"><ndarray 2="" @cpu(0)=""></ndarray></span>
<span class="gp">>>> </span><span class="n">scale</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">])</span>
<span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">exponential</span><span class="p">(</span><span class="n">scale</span><span class="p">,</span> <span class="n">shape</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="go">[[ 0.41063145 0.42140478]</span>
<span class="go"> [ 2.59407091 10.12439728]</span>
<span class="go"> [ 2.42544937 1.14260709]]</span>
<span class="go"><ndarray 3x2="" @cpu(0)=""></ndarray></span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="mxnet.ndarray.random.gamma">
<code class="descclassname">mxnet.ndarray.random.</code><code class="descname">gamma</code><span class="sig-paren">(</span><em>alpha=1</em>, <em>beta=1</em>, <em>shape=_Null</em>, <em>dtype=_Null</em>, <em>ctx=None</em>, <em>out=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.ndarray.random.gamma" title="Permalink to this definition"></a></dt>
<dd><p>Draw random samples from a gamma distribution.</p>
<p>Samples are distributed according to a gamma distribution parametrized
by <em>alpha</em> (shape) and <em>beta</em> (scale).</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>alpha</strong> (<em>float or NDArray</em>) – The shape of the gamma distribution. Should be greater than zero.</li>
<li><strong>beta</strong> (<em>float or NDArray</em>) – The scale of the gamma distribution. Should be greater than zero.
Default is equal to 1.</li>
<li><strong>shape</strong> (<em>int or tuple of ints</em>) – The number of samples to draw. If shape is, e.g., <cite>(m, n)</cite> and <cite>alpha</cite> and
<cite>beta</cite> are scalars, output shape will be <cite>(m, n)</cite>. If <cite>alpha</cite> and <cite>beta</cite>
are NDArrays with shape, e.g., <cite>(x, y)</cite>, then output will have shape
<cite>(x, y, m, n)</cite>, where <cite>m*n</cite> samples are drawn for each <cite>[alpha, beta)</cite> pair.</li>
<li><strong>dtype</strong> (<em>{'float16','float32', 'float64'}</em>) – Data type of output samples. Default is ‘float32’</li>
<li><strong>ctx</strong> (<em>Context</em>) – Device context of output. Default is current context. Overridden by
<cite>alpha.context</cite> when <cite>alpha</cite> is an NDArray.</li>
<li><strong>out</strong> (<a class="reference internal" href="ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray"><em>NDArray</em></a>) – Store output to an existing NDArray.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Examples</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">gamma</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
<span class="go">[ 1.93308783]</span>
<span class="go"><ndarray 1="" @cpu(0)=""></ndarray></span>
<span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">gamma</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="n">shape</span><span class="o">=</span><span class="p">(</span><span class="mi">2</span><span class="p">,))</span>
<span class="go">[ 0.48216391 2.09890771]</span>
<span class="go"><ndarray 2="" @cpu(0)=""></ndarray></span>
<span class="gp">>>> </span><span class="n">alpha</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">])</span>
<span class="gp">>>> </span><span class="n">beta</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">,</span><span class="mi">4</span><span class="p">])</span>
<span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">gamma</span><span class="p">(</span><span class="n">alpha</span><span class="p">,</span> <span class="n">beta</span><span class="p">,</span> <span class="n">shape</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="go">[[ 3.24343276 0.94137681]</span>
<span class="go"> [ 3.52734375 0.45568955]</span>
<span class="go"> [ 14.26264095 14.0170126 ]]</span>
<span class="go"><ndarray 3x2="" @cpu(0)=""></ndarray></span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="mxnet.ndarray.random.negative_binomial">
<code class="descclassname">mxnet.ndarray.random.</code><code class="descname">negative_binomial</code><span class="sig-paren">(</span><em>k=1</em>, <em>p=1</em>, <em>shape=_Null</em>, <em>dtype=_Null</em>, <em>ctx=None</em>, <em>out=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.ndarray.random.negative_binomial" title="Permalink to this definition"></a></dt>
<dd><p>Draw random samples from a negative binomial distribution.</p>
<p>Samples are distributed according to a negative binomial distribution
parametrized by <em>k</em> (limit of unsuccessful experiments) and <em>p</em> (failure
probability in each experiment). Samples will always be returned as a
floating point data type.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>k</strong> (<em>float or NDArray</em>) – Limit of unsuccessful experiments, > 0.</li>
<li><strong>p</strong> (<em>float or NDArray</em>) – Failure probability in each experiment, >= 0 and <=1.</li>
<li><strong>shape</strong> (<em>int or tuple of ints</em>) – The number of samples to draw. If shape is, e.g., <cite>(m, n)</cite> and <cite>k</cite> and
<cite>p</cite> are scalars, output shape will be <cite>(m, n)</cite>. If <cite>k</cite> and <cite>p</cite>
are NDArrays with shape, e.g., <cite>(x, y)</cite>, then output will have shape
<cite>(x, y, m, n)</cite>, where <cite>m*n</cite> samples are drawn for each <cite>[k, p)</cite> pair.</li>
<li><strong>dtype</strong> (<em>{'float16','float32', 'float64'}</em>) – Data type of output samples. Default is ‘float32’</li>
<li><strong>ctx</strong> (<em>Context</em>) – Device context of output. Default is current context. Overridden by
<cite>k.context</cite> when <cite>k</cite> is an NDArray.</li>
<li><strong>out</strong> (<a class="reference internal" href="ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray"><em>NDArray</em></a>) – Store output to an existing NDArray.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Examples</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">negative_binomial</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">)</span>
<span class="go">[ 4.]</span>
<span class="go"><ndarray 1="" @cpu(0)=""></ndarray></span>
<span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">negative_binomial</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">,</span> <span class="n">shape</span><span class="o">=</span><span class="p">(</span><span class="mi">2</span><span class="p">,))</span>
<span class="go">[ 3. 4.]</span>
<span class="go"><ndarray 2="" @cpu(0)=""></ndarray></span>
<span class="gp">>>> </span><span class="n">k</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">])</span>
<span class="gp">>>> </span><span class="n">p</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mf">0.2</span><span class="p">,</span><span class="mf">0.4</span><span class="p">,</span><span class="mf">0.6</span><span class="p">])</span>
<span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">negative_binomial</span><span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">p</span><span class="p">,</span> <span class="n">shape</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="go">[[ 3. 2.]</span>
<span class="go"> [ 4. 4.]</span>
<span class="go"> [ 0. 5.]]</span>
<span class="go"><ndarray 3x2="" @cpu(0)=""></ndarray></span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="mxnet.ndarray.random.generalized_negative_binomial">
<code class="descclassname">mxnet.ndarray.random.</code><code class="descname">generalized_negative_binomial</code><span class="sig-paren">(</span><em>mu=1</em>, <em>alpha=1</em>, <em>shape=_Null</em>, <em>dtype=_Null</em>, <em>ctx=None</em>, <em>out=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.ndarray.random.generalized_negative_binomial" title="Permalink to this definition"></a></dt>
<dd><p>Draw random samples from a generalized negative binomial distribution.</p>
<p>Samples are distributed according to a generalized negative binomial
distribution parametrized by <em>mu</em> (mean) and <em>alpha</em> (dispersion).
<em>alpha</em> is defined as <em>1/k</em> where <em>k</em> is the failure limit of the
number of unsuccessful experiments (generalized to real numbers).
Samples will always be returned as a floating point data type.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>mu</strong> (<em>float or NDArray</em>) – Mean of the negative binomial distribution.</li>
<li><strong>alpha</strong> (<em>float or NDArray</em>) – Alpha (dispersion) parameter of the negative binomial distribution.</li>
<li><strong>shape</strong> (<em>int or tuple of ints</em>) – The number of samples to draw. If shape is, e.g., <cite>(m, n)</cite> and <cite>mu</cite> and
<cite>alpha</cite> are scalars, output shape will be <cite>(m, n)</cite>. If <cite>mu</cite> and <cite>alpha</cite>
are NDArrays with shape, e.g., <cite>(x, y)</cite>, then output will have shape
<cite>(x, y, m, n)</cite>, where <cite>m*n</cite> samples are drawn for each <cite>[mu, alpha)</cite> pair.</li>
<li><strong>dtype</strong> (<em>{'float16','float32', 'float64'}</em>) – Data type of output samples. Default is ‘float32’</li>
<li><strong>ctx</strong> (<em>Context</em>) – Device context of output. Default is current context. Overridden by
<cite>mu.context</cite> when <cite>mu</cite> is an NDArray.</li>
<li><strong>out</strong> (<a class="reference internal" href="ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray"><em>NDArray</em></a>) – Store output to an existing NDArray.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Examples</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">generalized_negative_binomial</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">)</span>
<span class="go">[ 19.]</span>
<span class="go"><ndarray 1="" @cpu(0)=""></ndarray></span>
<span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">generalized_negative_binomial</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span> <span class="mf">0.5</span><span class="p">,</span> <span class="n">shape</span><span class="o">=</span><span class="p">(</span><span class="mi">2</span><span class="p">,))</span>
<span class="go">[ 30. 21.]</span>
<span class="go"><ndarray 2="" @cpu(0)=""></ndarray></span>
<span class="gp">>>> </span><span class="n">mu</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mi">1</span><span class="p">,</span><span class="mi">2</span><span class="p">,</span><span class="mi">3</span><span class="p">])</span>
<span class="gp">>>> </span><span class="n">alpha</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="mf">0.2</span><span class="p">,</span><span class="mf">0.4</span><span class="p">,</span><span class="mf">0.6</span><span class="p">])</span>
<span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">generalized_negative_binomial</span><span class="p">(</span><span class="n">mu</span><span class="p">,</span> <span class="n">alpha</span><span class="p">,</span> <span class="n">shape</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="go">[[ 4. 0.]</span>
<span class="go"> [ 3. 2.]</span>
<span class="go"> [ 6. 2.]]</span>
<span class="go"><ndarray 3x2="" @cpu(0)=""></ndarray></span>
</pre></div>
</div>
</dd></dl>
<dl class="function">
<dt id="mxnet.ndarray.random.multinomial">
<code class="descclassname">mxnet.ndarray.random.</code><code class="descname">multinomial</code><span class="sig-paren">(</span><em>data</em>, <em>shape=_Null</em>, <em>get_prob=False</em>, <em>out=None</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.ndarray.random.multinomial" title="Permalink to this definition"></a></dt>
<dd><p>Concurrent sampling from multiple multinomial distributions.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">The input distribution must be normalized, i.e. <cite>data</cite> must sum to
1 along its last dimension.</p>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>data</strong> (<a class="reference internal" href="ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray"><em>NDArray</em></a>) – An <em>n</em> dimensional array whose last dimension has length <cite>k</cite>, where
<cite>k</cite> is the number of possible outcomes of each multinomial distribution.
For example, data with shape <cite>(m, n, k)</cite> specifies <cite>m*n</cite> multinomial
distributions each with <cite>k</cite> possible outcomes.</li>
<li><strong>shape</strong> (<em>int or tuple of ints</em>) – The number of samples to draw from each distribution. If shape is empty
one sample will be drawn from each distribution.</li>
<li><strong>get_prob</strong> (<em>bool</em>) – If true, a second array containing log likelihood of the drawn
samples will also be returned.
This is usually used for reinforcement learning, where you can provide
reward as head gradient w.r.t. this array to estimate gradient.</li>
<li><strong>out</strong> (<a class="reference internal" href="ndarray.html#mxnet.ndarray.NDArray" title="mxnet.ndarray.NDArray"><em>NDArray</em></a>) – Store output to an existing NDArray.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<p class="rubric">Examples</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="n">probs</span> <span class="o">=</span> <span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">array</span><span class="p">([[</span><span class="mi">0</span><span class="p">,</span> <span class="mf">0.1</span><span class="p">,</span> <span class="mf">0.2</span><span class="p">,</span> <span class="mf">0.3</span><span class="p">,</span> <span class="mf">0.4</span><span class="p">],</span> <span class="p">[</span><span class="mf">0.4</span><span class="p">,</span> <span class="mf">0.3</span><span class="p">,</span> <span class="mf">0.2</span><span class="p">,</span> <span class="mf">0.1</span><span class="p">,</span> <span class="mi">0</span><span class="p">]])</span>
<span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">multinomial</span><span class="p">(</span><span class="n">probs</span><span class="p">)</span>
<span class="go">[3 1]</span>
<span class="go"><ndarray 2="" @cpu(0)=""></ndarray></span>
<span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">multinomial</span><span class="p">(</span><span class="n">probs</span><span class="p">,</span> <span class="n">shape</span><span class="o">=</span><span class="mi">2</span><span class="p">)</span>
<span class="go">[[4 4]</span>
<span class="go"> [1 2]]</span>
<span class="go"><ndarray 2x2="" @cpu(0)=""></ndarray></span>
<span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">multinomial</span><span class="p">(</span><span class="n">probs</span><span class="p">,</span> <span class="n">get_prob</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span>
<span class="go">[3 2]</span>
<span class="go"><ndarray 2="" @cpu(0)=""></ndarray></span>
<span class="go">[-1.20397282 -1.60943794]</span>
<span class="go"><ndarray 2="" @cpu(0)=""></ndarray></span>
</pre></div>
</div>
</dd></dl>
<span class="target" id="module-mxnet.random"></span><p>Random number interface of MXNet.</p>
<dl class="function">
<dt id="mxnet.random.seed">
<code class="descclassname">mxnet.random.</code><code class="descname">seed</code><span class="sig-paren">(</span><em>seed_state</em><span class="sig-paren">)</span><a class="headerlink" href="#mxnet.random.seed" title="Permalink to this definition"></a></dt>
<dd><p>Seeds the random number generators in MXNet.</p>
<p>This affects the behavior of modules in MXNet that uses random number generators,
like the dropout operator and <cite>NDArray</cite>‘s random sampling operators.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name"/>
<col class="field-body"/>
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>seed_state</strong> (<em>int</em>) – The random number seed to set to all devices.</td>
</tr>
</tbody>
</table>
<p class="rubric">Notes</p>
<p>Random number generators in MXNet are device specific. Therefore, random numbers
generated from two devices can be different even if they are seeded using the same seed.</p>
<p class="rubric">Example</p>
<div class="highlight-python"><div class="highlight"><pre><span></span><span class="gp">>>> </span><span class="k">print</span><span class="p">(</span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">normal</span><span class="p">(</span><span class="n">shape</span><span class="o">=</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">2</span><span class="p">))</span><span class="o">.</span><span class="n">asnumpy</span><span class="p">())</span>
<span class="go">[[ 1.36481571 -0.62203991]</span>
<span class="go"> [-1.4962182 -0.08511394]]</span>
<span class="gp">>>> </span><span class="k">print</span><span class="p">(</span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">normal</span><span class="p">(</span><span class="n">shape</span><span class="o">=</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">2</span><span class="p">))</span><span class="o">.</span><span class="n">asnumpy</span><span class="p">())</span>
<span class="go">[[ 1.09544981 -0.20014545]</span>
<span class="go"> [-0.20808885 0.2527658 ]]</span>
<span class="go">>>></span>
<span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">seed</span><span class="p">(</span><span class="mi">128</span><span class="p">)</span>
<span class="gp">>>> </span><span class="k">print</span><span class="p">(</span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">normal</span><span class="p">(</span><span class="n">shape</span><span class="o">=</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">2</span><span class="p">))</span><span class="o">.</span><span class="n">asnumpy</span><span class="p">())</span>
<span class="go">[[ 0.47400656 -0.75213492]</span>
<span class="go"> [ 0.20251541 0.95352972]]</span>
<span class="gp">>>> </span><span class="n">mx</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">seed</span><span class="p">(</span><span class="mi">128</span><span class="p">)</span>
<span class="gp">>>> </span><span class="k">print</span><span class="p">(</span><span class="n">mx</span><span class="o">.</span><span class="n">nd</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">normal</span><span class="p">(</span><span class="n">shape</span><span class="o">=</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="mi">2</span><span class="p">))</span><span class="o">.</span><span class="n">asnumpy</span><span class="p">())</span>
<span class="go">[[ 0.47400656 -0.75213492]</span>
<span class="go"> [ 0.20251541 0.95352972]]</span>
</pre></div>
</div>
</dd></dl>
<script>auto_index("api-reference");</script></div>
</div>
</div>
</div>
<div aria-label="main navigation" class="sphinxsidebar rightsidebar" role="navigation">
<div class="sphinxsidebarwrapper">
<h3><a href="../../../index.html">Table Of Contents</a></h3>
<ul>
<li><a class="reference internal" href="#">Random Distribution Generator NDArray API</a><ul>
<li><a class="reference internal" href="#overview">Overview</a></li>
<li><a class="reference internal" href="#random-distribution-generator">Random Distribution Generator</a></li>
<li><a class="reference internal" href="#api-reference">API Reference</a></li>
</ul>
</li>
</ul>
</div>
</div>
</div><div class="footer">
<div class="section-disclaimer">
<div class="container">
<div>
<img height="60" src="https://raw.githubusercontent.com/dmlc/web-data/master/mxnet/image/apache_incubator_logo.png"/>
<p>
Apache MXNet is an effort undergoing incubation at The Apache Software Foundation (ASF), <strong>sponsored by the <i>Apache Incubator</i></strong>. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.
</p>
<p>
"Copyright © 2017, The Apache Software Foundation
Apache MXNet, MXNet, Apache, the Apache feather, and the Apache MXNet project logo are either registered trademarks or trademarks of the Apache Software Foundation."
</p>
</div>
</div>
</div>
</div> <!-- pagename != index -->
</div>
<script crossorigin="anonymous" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script src="../../../_static/js/sidebar.js" type="text/javascript"></script>
<script src="../../../_static/js/search.js" type="text/javascript"></script>
<script src="../../../_static/js/navbar.js" type="text/javascript"></script>
<script src="../../../_static/js/clipboard.min.js" type="text/javascript"></script>
<script src="../../../_static/js/copycode.js" type="text/javascript"></script>
<script src="../../../_static/js/page.js" type="text/javascript"></script>
<script type="text/javascript">
$('body').ready(function () {
$('body').css('visibility', 'visible');
});
</script>
</body>
</html>