Your Title - statistics 2019-05-20T00:28:35-03:00 http://example.com/tag/statistics.html Author Here Gaussian Processes for Classification and Regression: Introduction and Usage 2017-11-19T17:12:44-02:00 http://example.com/entries/gaussian-processes-for-classification-introduction-and-usage <blockquote> <p><span style="font-weight:bold">Please note</span> This post is mainly intended for my <strong>personal use</strong>. It is not peer-reviewed work and should not be taken as such.</p> </blockquote> <h2 id="tl-dr">TL;DR.</h2> <p>Like other Bayesian methods, Gaussian processes can be used for classification and regression in a way that also explicitly specifies the confidence interval of the predictions. You can also use Kernels to inform the algorithm with problem-specific data structure.</p> <p><div class="img-div" markdown="1"> <img src="http://queirozf.com/images/contents/I7lN4ww.png" alt="gaussian-processes-fit-on-samples"> <em>Example of Gaussian Processes fitted on a couple of noisy observations (black crosses). Pink line shows actual function, black line shows the mean of the prediction, grey area indicates margin of error. <br /> Source: Slides from UToronto (See refs)</em> </div></p> <h2 id="prereq-probabilistic-intepretation-of-linear-regression">Prereq: Probabilistic Intepretation of Linear Regression</h2> <p>The parameters that maximize:</p> <ul> <li>the log-likelihood that the curve fits the points, assuming that each point contains an error that follows the normal distribution <em>and</em> that this error is independent among samples.</li> </ul> <p>Are the <strong>very same</strong> parameters that minimize:</p> <ul> <li>the least squares cost function, as used in ordinary least squares.</li> </ul> <p><strong>In other words</strong> least squares linear regression can be viewed as a maximum likelihood estimation (MLE) of the one set of parameters (theta, sigma) that maximize the likelihood that each sampled point in our dataset can be explained as a curve with parameters <code>theta</code> with some random noise (with mean on the curve itself and variance <code>sigma</code>).</p> <p><div class="img-div" markdown="1"> <img src="http://queirozf.com/images/contents/G9pamr7.png" alt="likelihood-linear-regression"> <em>Probabilistic Linear Regression: The likelihood of the parameters <code>theta</code> given targets <code>y_i</code> and samples <code>x_i</code> for a dataset containing <code>m</code> observations. <br />Adapted from: Stanford CS229 Lecture Notes</em> </div></p> <h2 id="prereq-bayesian-regularization">Prereq: Bayesian Regularization</h2> <p>A <strong>bayesian approach</strong> to a problem generally means treating every parameter configuration as a full distribution over values, and then using Bayes&#39; rule to get the posterior probability of some configuration.</p> <blockquote> <p>In other words, each parameter in the model is a bayesian random variable, with priors and the <strong>optimal</strong> value for the parameter is the value that maximizes its posterior distribution.</p> </blockquote> <p>This allows for using external prior information to get a more accurate model, but more importantly, <strong>it acts as a regularizer</strong> because you are forced to take into account the priors of other parameter configurations too.</p> <p>In other words, you multiply the value for the MLE/MAP estimation for a parameter configuration by the prior for that configuration.</p> <div style="text-align:center; margin-bottom: 7px; margin-top: 7px;"> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- ab_test_large_square --> <ins class="adsbygoogle" style="display:inline-block;width:336px;height:280px" data-ad-client="ca-pub-2217532725941275" data-ad-slot="7164375745"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <h2 id="prereq-kernels">Prereq: Kernels</h2> <p><strong>Kernels</strong> are functions that return the inner product between two points in another vector space.</p> <p>This is useful because many methods use inner products as a measure of <em>similarity</em> between two points and you can use kernels to discover the <em>similarity</em> of two points in another (higher-dimensional, nonlinear) space, <strong>without needing to directly calculate the projection of each point in that space</strong>.</p> <p><strong>Another explanation:</strong> A kernel is a function <code>f(,)</code> such that if you compute <code>f(a,b)</code> for every pair of elements in some S, you get a positive semidefinite matrix (i.e. a covariance matrix).</p> <h2 id="properties-of-multivariate-gaussians">Properties of Multivariate Gaussians</h2> <p><div class="img-div" markdown="1"> <img src="http://queirozf.com/images/contents/PSsEuhL.png" alt="2d-gaussian-distribution"> <em>2D Gaussian distribution with mean (0,0) and Identity Matrix for Covariances <br /> Source: User Kghose at the English language Wikipedia (<a href="https://upload.wikimedia.org/wikipedia/commons/c/ce/Gaussian_2d.png">original link</a>)</em> </div></p> <p>Given a N-dimensional random variable <strong>X</strong> that follows a (multivariate) Gaussian distribution:</p> <ul> <li><p><strong>The density function sums to one.</strong> (Obvious but it&#39;s worth remembering)</p></li> <li><p>Any <strong>linear combination of its components</strong> is also Gaussian. </p></li> <li><p><strong>The marginal densities</strong> of any subset of elements are also Gaussians.</p></li> <li><p><strong>The conditional densities</strong> of any subset of elements given another subset is also Gaussian.</p></li> <li><p><strong>The sum of independent Gaussian random variables</strong> is also Gaussian.</p></li> <li><p>If the individual components of <strong>X</strong> are each normally distributed and they are independent, then <strong>X</strong> is a multivariate Gaussian.</p></li> </ul> <h2 id="probability-distributions-over-functions-with-finite-domains">Probability distributions over functions with finite domains</h2> <p>If you have a finite number of inputs (say the number of samples, <code>m</code>), you can view the mapping of features to target values as a function, but you can represent it using a <code>m</code>-dimensional vector of real numbers, one for each input.</p> <p>But since this is just an <code>n</code>-dimensional array, you can view it as a distribution over values, rather than as just a single, static, set of values.</p> <p>This is what is meant by a distribution over functions with finite domains.</p> <div style="text-align:center; margin-bottom: 7px; margin-top: 7px;"> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- ab_test_large_square --> <ins class="adsbygoogle" style="display:inline-block;width:336px;height:280px" data-ad-client="ca-pub-2217532725941275" data-ad-slot="7164375745"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <h2 id="gaussian-processes">Gaussian Processes</h2> <p>A <strong>Gaussian Process</strong> is the generalization of the above (distribution over functions with finite domains) in the infinite domain.</p> <p>This is achieved by sampling <strong>mean functions</strong> <code>m(x_1)</code> and <strong>covariance functions</strong> <code>k(x_1,x_2)</code> that return the mean to be used to generate the Gaussian distribution to sample the first element and also the covariance function between every pair of variables.</p> <p>The <strong>interesting thing is</strong> that, while any function is a valid mean function, not every function is a valid covariance. </p> <p>Only a certain type of function can be used as a covariance function for a multivariate Gaussian distribution: a <strong>Kernel</strong>.</p> <h2 id="usage-in-classification-regression">Usage in Classification/Regression</h2> <p>As in the probabilistic linear regression case, we will assume our samples in the training set can be modelled by some function <code>Z</code> plus some gaussian noise.</p> <p>So when doing regression, we actually are trying to find out the most likely distribution (i.e. highest posterior probability) of the values in the test set <em>given</em> the values in the training set.</p> <p>But if we take function <code>Z</code> itself to be a <strong>Gaussian Process</strong>, we can use all those properties of multivariate gaussians stated earlier (sum of gaussians is also gaussian, conditional distribution of a subset is also gaussian).</p> <p>Such a choice of assumptions allows us to calculate the posterior distribution (or just the most likely values) for the test targets, given the training targets.</p> <blockquote> <p>Gaussian Processes for Regression are <strong>a generalization of Bayesian Linear regression</strong>.</p> </blockquote> <p>For <strong>classification</strong> problems, one simple way to adapt gaussian processes is to choose a 0-1 loss (i.e. punish false positives and false negatives equally), normalize the target into a 0-1 interval (e.g. using the logistic function) so that it can be viewed as a probability and choosing some threshold value for actual classification.</p> <div style="text-align:center; margin-bottom: 7px; margin-top: 7px;"> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- ab_test_medium_square --> <ins class="adsbygoogle" style="display:inline-block;width:300px;height:250px" data-ad-client="ca-pub-2217532725941275" data-ad-slot="3340325586"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <h2 id="sparse-gaussian-processes">Sparse Gaussian Processes</h2> <p>Gaussian processes are powerful general-purpose models but fitting the model to training data is potentially <strong>very time-consuming</strong> (exponential time on the number of samples) due to operations such as inverting the covariance matrix.</p> <p><strong>Sparse gaussian processes</strong> refer to techniques in which only a subset of the training samples deemed <strong>more informative</strong> is selected for training. This presents a tradeoff between training time and model accuracy.</p> <hr> <h3 id="references">References</h3> <ul> <li><p><a href="http://cs229.stanford.edu/section/cs229-gaussian_processes.pdf">Stanford CS229: Gaussian Processes</a></p></li> <li><p><a href="https://www.quora.com/What-are-the-advantages-of-Bayesian-methods-over-frequentist-methods-in-web-data?srid=J6h5">Quora: What are the advantages of Bayesian methods over frequentist methods in web data?</a></p> <ul> <li>See the first answer for a good answer on how Bayesian priors can be used as regularizers.</li> </ul></li> <li><p><a href="http://cs229.stanford.edu/section/gaussians.pdf">Stanford CS229: The Multivariate Gaussian Distribution</a></p></li> <li><p><a href="https://www.cs.toronto.edu/%7Ehinton/csc2515/notes/gp_slides_fall08.pdf">UToronto: Introduction to Gaussian Processes, Slides by Iain Murray</a></p></li> <li><p><a href="https://www.youtube.com/watch?v=TbAbwtnTbZM">Mathematical Monk: Gaussian coordinates do not imply multivariate Gaussian</a></p> <ul> <li>This is just one of the videos on this theme. This guy has 11 videos dealing with Gaussian Processes overall.</li> </ul></li> </ul> Numpy Distributions and Statistical Functions: Examples + Reference 2016-09-10T20:35:18-03:00 http://example.com/entries/numpy-distributions-and-statistical-functions-examples-reference <blockquote> <p><strong>HEADS-UP</strong>: In general, leave out the <code>size=</code> parameter if you just want a sample with a single element</p> </blockquote> <h2 id="generate-random-number-from-0-up-to-n">Generate random number from 0 up to N</h2> <p>All integers from 0 (inclusive) to N-1 have equal probability</p> <p><strong>Template:</strong> <code>np.random.randint(0, N)</code></p> <div class="highlight"><pre><code class="language-python" data-lang="python"><span class="kn">import</span> <span class="nn">numpy</span> <span class="kn">as</span> <span class="nn">np</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randint</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span><span class="mi">100</span><span class="p">)</span> <span class="c"># 56</span> </code></pre></div> <div style="text-align:center; margin-bottom: 7px; margin-top: 7px;"> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- ab_test_large_square --> <ins class="adsbygoogle" style="display:inline-block;width:336px;height:280px" data-ad-client="ca-pub-2217532725941275" data-ad-slot="7164375745"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <h2 id="generate-random-number-in-interval">Generate random number in interval</h2> <p><strong>Template:</strong> <code>np.random.randint(A, B)</code></p> <p>Again, all integers from A (inclusive) up to B-1 have equal probability</p> <div class="highlight"><pre><code class="language-python" data-lang="python"><span class="kn">import</span> <span class="nn">numpy</span> <span class="kn">as</span> <span class="nn">np</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randint</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span><span class="mi">15</span><span class="p">)</span> <span class="c"># 12</span> </code></pre></div> <h2 id="generate-random-number-between-0-and-1">Generate random number between 0 and 1</h2> <p>Generate a random number (real) from 0 (including) up to 0.99999... (depending on precision).</p> <p>All real numbers from 0 to 0.99999... are generated with equal probability.</p> <div class="highlight"><pre><code class="language-python" data-lang="python"><span class="kn">import</span> <span class="nn">numpy</span> <span class="kn">as</span> <span class="nn">np</span> <span class="c"># this is equivalent to np.random.uniform(low=0,high=1)</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">sample</span><span class="p">()</span> <span class="c"># 0.30220482</span> </code></pre></div> <div style="text-align:center; margin-bottom: 7px; margin-top: 7px;"> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- ab_test_medium_square --> <ins class="adsbygoogle" style="display:inline-block;width:300px;height:250px" data-ad-client="ca-pub-2217532725941275" data-ad-slot="3340325586"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <h2 id="sample-from-standard-normal-distribution">Sample from standard normal distribution</h2> <div class="highlight"><pre><code class="language-python" data-lang="python"><span class="kn">import</span> <span class="nn">numpy</span> <span class="kn">as</span> <span class="nn">np</span> <span class="c"># mean at zero and standard deviation of 1</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">randn</span><span class="p">(</span><span class="mi">10</span><span class="p">)</span> <span class="c"># array([ 0.32929561, -0.5814358 , 0.74105779, 0.06120152, 1.02753804,</span> <span class="c"># 0.2814268 , 0.76394055, -0.13202086, -0.99976205, -0.51692293])</span> </code></pre></div> <h2 id="sample-from-arbitrary-normal-distribution">Sample from arbitrary normal distribution</h2> <div class="highlight"><pre><code class="language-python" data-lang="python"><span class="kn">import</span> <span class="nn">numpy</span> <span class="kn">as</span> <span class="nn">np</span> <span class="c"># an array of 10 points randomly sampled from a normal distribution</span> <span class="c"># loc=mean, scale=std deviation</span> <span class="n">np</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="o">=</span><span class="mf">0.0</span><span class="p">,</span> <span class="n">scale</span><span class="o">=</span><span class="mf">1.0</span><span class="p">,</span> <span class="n">size</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span> <span class="c"># array([ 0.57258901, 2.25547575, 0.65749017, -0.04182533, 0.55000601,</span> <span class="c"># -1.15594624, 0.32455692, 0.16460812, 0.70899117, -0.95861313])</span> </code></pre></div> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <p><ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-2217532725941275" data-ad-slot="5851294071"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script></p> <h2 id="sample-from-uniform-distribution-continuous">Sample from uniform distribution (continuous)</h2> <div class="highlight"><pre><code class="language-python" data-lang="python"><span class="kn">import</span> <span class="nn">numpy</span> <span class="kn">as</span> <span class="nn">np</span> <span class="n">np</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="o">=</span><span class="mi">0</span><span class="p">,</span><span class="n">high</span><span class="o">=</span><span class="mi">1</span><span class="p">,</span><span class="n">size</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span> <span class="c"># array([ 0.21310048, 0.28180847, 0.58721479, 0.8013283 , 0.33171448,</span> <span class="c"># 0.98888729, 0.4519467 , 0.93362951, 0.64370449, 0.13997242])</span> </code></pre></div> <h2 id="sample-from-uniform-distribution-discrete">Sample from uniform distribution (discrete)</h2> <div class="highlight"><pre><code class="language-python" data-lang="python"><span class="kn">import</span> <span class="nn">numpy</span> <span class="kn">as</span> <span class="nn">np</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">choice</span><span class="p">(</span><span class="mi">10</span><span class="p">,</span><span class="n">size</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span> <span class="c"># array([2, 8, 2, 7, 7, 9, 1, 7, 9, 5])</span> </code></pre></div> <h2 id="sample-from-lists-arrays-without-replacement">Sample from lists/arrays, without replacement</h2> <blockquote> <p>To enable replacement, use <code>replace=True</code></p> </blockquote> <div class="highlight"><pre><code class="language-python" data-lang="python"><span class="kn">import</span> <span class="nn">numpy</span> <span class="kn">as</span> <span class="nn">np</span> <span class="n">lst</span> <span class="o">=</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="mi">4</span><span class="p">,</span><span class="mi">5</span><span class="p">,</span><span class="mi">6</span><span class="p">,</span><span class="mi">7</span><span class="p">,</span><span class="mi">8</span><span class="p">,</span><span class="mi">9</span><span class="p">]</span> <span class="n">np</span><span class="o">.</span><span class="n">random</span><span class="o">.</span><span class="n">choice</span><span class="p">(</span><span class="n">lst</span><span class="p">,</span><span class="n">size</span><span class="o">=</span><span class="mi">5</span><span class="p">,</span><span class="n">replace</span><span class="o">=</span><span class="bp">False</span><span class="p">)</span> <span class="c"># array([8, 2, 7, 5, 1])</span> </code></pre></div> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <p><ins class="adsbygoogle" style="display:block; text-align:center;" data-ad-layout="in-article" data-ad-format="fluid" data-ad-client="ca-pub-2217532725941275" data-ad-slot="5851294071"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script></p> <h2 id="evaluate-x-on-a-gaussian-pdf">Evaluate x on a gaussian PDF</h2> <blockquote> <p><strong>In other words</strong>, P(x) | P ~ Gaussian(0,1) </p> </blockquote> <div class="highlight"><pre><code class="language-python" data-lang="python"><span class="kn">import</span> <span class="nn">scipy.stats</span> <span class="kn">as</span> <span class="nn">st</span> <span class="n">dist</span> <span class="o">=</span> <span class="n">st</span><span class="o">.</span><span class="n">norm</span><span class="p">(</span><span class="n">loc</span><span class="o">=</span><span class="mf">0.0</span><span class="p">,</span><span class="n">scale</span><span class="o">=</span><span class="mf">1.0</span><span class="p">)</span> <span class="n">dist</span><span class="o">.</span><span class="n">pdf</span><span class="p">(</span><span class="mf">1.645</span><span class="p">)</span> <span class="c"># 0.10311081109198142</span> </code></pre></div> <h2 id="evaluate-x-on-a-gaussian-cdf">Evaluate x on a Gaussian CDF</h2> <blockquote> <p><strong>In other words</strong>, what percentage of the density is to the left of x?</p> </blockquote> <div class="highlight"><pre><code class="language-python" data-lang="python"><span class="kn">import</span> <span class="nn">scipy.stats</span> <span class="kn">as</span> <span class="nn">st</span> <span class="n">dist</span> <span class="o">=</span> <span class="n">st</span><span class="o">.</span><span class="n">norm</span><span class="p">(</span><span class="n">loc</span><span class="o">=</span><span class="mf">0.0</span><span class="p">,</span><span class="n">scale</span><span class="o">=</span><span class="mf">1.0</span><span class="p">)</span> <span class="n">dist</span><span class="o">.</span><span class="n">cdf</span><span class="p">(</span><span class="mf">1.645</span><span class="p">)</span> <span class="c"># 0.95001509446087862</span> </code></pre></div> <div style="text-align:center; margin-bottom: 7px; margin-top: 7px;"> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- ab_test_medium_square --> <ins class="adsbygoogle" style="display:inline-block;width:300px;height:250px" data-ad-client="ca-pub-2217532725941275" data-ad-slot="3340325586"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <h2 id="linspace-vs-arange">linspace VS arange</h2> <blockquote> <p>Use <code>linspace</code> if you care about the number of elements, use <code>arange</code> if you care about the step size</p> </blockquote> <h2 id="generate-n-samples-evenly-spaced">Generate N samples, evenly spaced</h2> <p>In this case generate 11 samples evenly spaced from 0.0 to 1.0</p> <div class="highlight"><pre><code class="language-python" data-lang="python"><span class="kn">import</span> <span class="nn">numpy</span> <span class="kn">as</span> <span class="nn">np</span> <span class="c"># template is: linspace(start, stop, num=50)</span> <span class="n">x</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">linspace</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span><span class="mf">1.0</span><span class="p">,</span><span class="mi">11</span><span class="p">)</span> <span class="c"># array([ 0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1. ])</span> </code></pre></div> <h2 id="generate-samples-evenly-spaced-with-step-size">Generate samples, evenly spaced with step size</h2> <blockquote> <p>template: <code>arange(start, stop, step)</code></p> </blockquote> <div class="highlight"><pre><code class="language-python" data-lang="python"><span class="kn">import</span> <span class="nn">numpy</span> <span class="kn">as</span> <span class="nn">np</span> <span class="c"># template is: arange(start, stop, step)</span> <span class="n">x</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">arange</span><span class="p">(</span><span class="mf">0.0</span><span class="p">,</span><span class="mf">10.0</span><span class="p">,</span><span class="mi">3</span><span class="p">)</span> <span class="c"># array([ 0., 3., 6., 9.])</span> </code></pre></div> <h2 id="generate-samples-in-logarithmic-scale">Generate samples in logarithmic scale</h2> <blockquote> <p>template: <code>logspace(start, stop, num=50)</code></p> </blockquote> <p>Generate numbers in logarithmic scale: 0.001, 0.01, 0.1, 1.0, 10.0, etc.</p> <div class="highlight"><pre><code class="language-python" data-lang="python"><span class="kn">import</span> <span class="nn">numpy</span> <span class="kn">as</span> <span class="nn">np</span> <span class="n">start</span><span class="o">=-</span><span class="mi">3</span> <span class="n">stop</span><span class="o">=</span><span class="mi">2</span> <span class="c"># num_elements is calculated using</span> <span class="c"># the range (start,stop) you chose above</span> <span class="n">num_elements</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="nb">abs</span><span class="p">([</span><span class="n">start</span><span class="p">,</span><span class="n">stop</span><span class="p">])</span><span class="o">.</span><span class="nb">sum</span><span class="p">()</span> <span class="o">+</span> <span class="mi">1</span> <span class="n">x</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">logspace</span><span class="p">(</span><span class="n">start</span><span class="p">,</span><span class="n">stop</span><span class="p">,</span><span class="n">num</span><span class="p">)</span> <span class="c"># array([ 1.00000000e-03, 1.00000000e-02, 1.00000000e-01,</span> <span class="c"># 1.00000000e+00, 1.00000000e+01, 1.00000000e+02])</span> </code></pre></div> <div style="text-align:center; margin-bottom: 7px; margin-top: 7px;"> <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- ab_test_medium_square --> <ins class="adsbygoogle" style="display:inline-block;width:300px;height:250px" data-ad-client="ca-pub-2217532725941275" data-ad-slot="3340325586"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> <hr> <h3 id="references">References</h3> <ul> <li><p><a href="http://docs.scipy.org/doc/numpy/reference/routines.random.html">Numpy Docs: Random Sampling (numpy.random)</a></p></li> <li><p><a href="http://stackoverflow.com/questions/20864847/probability-to-z-score-and-vice-versa-in-python">SO: Probability to Z-score and vice-versa in Python</a></p></li> </ul>