UNPKG

qminer

Version:

A C++ based data analytics platform for processing large-scale real-time streams containing structured and unstructured data

416 lines (412 loc) 17.1 kB
<!doctype html> <html> <head> <meta name="generator" content="JSDoc 3"> <meta charset="utf-8"> <title>Module: statistics</title> <link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Karla:400,400i,700,700i" type="text/css"> <link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Noto+Serif:400,400i,700,700i" type="text/css"> <link rel="stylesheet" href="https://brick.a.ssl.fastly.net/Inconsolata:500" type="text/css"> <link href="css/baseline.css" rel="stylesheet"> </head> <body onload="prettyPrint()"> <nav id="jsdoc-navbar" role="navigation" class="jsdoc-navbar"> <div id="jsdoc-navbar-container"> <div id="jsdoc-navbar-content"> <a href="index.html" class="jsdoc-navbar-package-name">QMiner JavaScript API v9.4.0</a> </div> </div> </nav> <div id="jsdoc-body-container"> <div id="jsdoc-content"> <div id="jsdoc-content-container"> <div id="jsdoc-main" role="main"> <header class="page-header"> <div class="symbol-detail-labels"><span class="label label-kind">module</span></div> <h1><small></small><span class="symbol-name">statistics</span></h1> <p class="source-link">Source: <a href="statdoc.js.html#source-line-8">statdoc.<wbr>js:8</a></p> <div class="symbol-description"> <p>Statistics module.</p> </div> <section> <h2> Example </h2> <div> <pre class="prettyprint"><code>// import the modules var qm &#x3D; require(&#x27;qminer&#x27;); var statistics &#x3D; qm.statistics; // create a vector var vec &#x3D; new qm.la.Vector([0, 1, 2, -1, -2]); // calculate the mean value of the vector var mean &#x3D; statistics.mean(vec); // returns 0</code></pre> </div> </section> <dl class="dl-compact"> </dl> </header> <section id="summary"> <div class="summary-callout"> <h2 class="summary-callout-heading">Methods</h2> <div class="summary-content"> <div class="summary-column"> <dl class="dl-summary-callout"> <dt><a href="module-statistics.html#.getZScore">getZScore(x, mu, sigma)</a></dt> <dd> </dd> <dt><a href="module-statistics.html#.mean">mean(input)</a></dt> <dd> </dd> </dl> </div> <div class="summary-column"> <dl class="dl-summary-callout"> <dt><a href="module-statistics.html#.std">std(X[, flag][, dim])</a></dt> <dd> </dd> <dt><a href="module-statistics.html#.zscore">zscore(mat[, flag][, dim])</a></dt> <dd> </dd> </dl> </div> <div class="summary-column"> </div> </div> </div> </section> <section> <h2>Methods</h2> <section> <div class="symbol-detail-labels"><span class="label label-static">static</span></div> <h3 id=".getZScore"><span class="symbol-name">getZScore</span><span class="signature"><span class="signature-params">(x, mu, sigma)</span>&nbsp;&rarr; <span class="signature-returns"> number</span></span></h3> <p>Calculates the z-score for a point sampled from a Gaussian distribution. The z-score indicates how many standard deviations an element is from the meam and can be calculated using the following formula: <code>z = (x - mu) / sigma</code>.</p> <section> <h4> Example </h4> <div> <pre class="prettyprint"><code>// import modules var stat &#x3D; require(&#x27;qminer&#x27;).statistics; // calculate the z-score of the sampled point var point &#x3D; 10; var mu &#x3D; 5; var sigma &#x3D; 5; var zScore &#x3D; stat.getZScore(point, mu, sigma); // returns 1</code></pre> </div> </section> <section> <h4>Parameters</h4> <table class="jsdoc-details-table"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Optional</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td> <p>x</p> </td> <td> <p>Number</p> </td> <td> <p>&nbsp;</p> </td> <td> <p>The sampled point.</p> </td> </tr> <tr> <td> <p>mu</p> </td> <td> <p>Number</p> </td> <td> <p>&nbsp;</p> </td> <td> <p>Mean of the distribution.</p> </td> </tr> <tr> <td> <p>sigma</p> </td> <td> <p>Number</p> </td> <td> <p>&nbsp;</p> </td> <td> <p>Variance of the distribution.</p> </td> </tr> </tbody> </table> </section> <dl class="dl-compact"> <dt>Returns</dt> <dd> <p><code>number</code>B The z-score of the sampled point.</p> </dd> </dl> <div class="symbol-detail-labels"><span class="label label-static">static</span></div> <h3 id=".mean"><span class="symbol-name">mean</span><span class="signature"><span class="signature-params">(input)</span>&nbsp;&rarr; <span class="signature-returns"> (number or <a href="module-la.Vector.html">module:la.Vector</a>)</span></span></h3> <p>Calculates the mean value(s).</p> <section> <h4> Example </h4> <div> <pre class="prettyprint"><code>// import modules var qm &#x3D; require(&#x27;qminer&#x27;); var la &#x3D; qm.la; var statistics &#x3D; qm.statistics; // create a matrix var mat &#x3D; new la.Matrix([[1, 2, 1], [-1, 2, -1], [3, 2, 3]]); // calculate the mean of the matrix columns // vector contains the elements [1, 2, 1] var mean &#x3D; statistics.mean(mat);</code></pre> </div> </section> <section> <h4>Parameter</h4> <table class="jsdoc-details-table"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Optional</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td> <p>input</p> </td> <td> <p>(<a href="module-la.Vector.html">module:la.Vector</a> or <a href="module-la.Matrix.html">module:la.Matrix</a>)</p> </td> <td> <p>&nbsp;</p> </td> <td> <p>The input the method is used on.</p> </td> </tr> </tbody> </table> </section> <dl class="dl-compact"> <dt>Returns</dt> <dd> <p><code>(number or <a href="module-la.Vector.html">module:la.Vector</a>)</code>B <br>1. If input is <a href="module-la.Vector.html">module:la.Vector</a>, returns the mean of the vector. <br>2. If input is <a href="module-la.Matrix.html">module:la.Matrix</a>, returns a vector of where the i-th value is the mean of i-th column. </p> </dd> </dl> <div class="symbol-detail-labels"><span class="label label-static">static</span></div> <h3 id=".std"><span class="symbol-name">std</span><span class="signature"><span class="signature-params">(X[, flag][, dim])</span>&nbsp;&rarr; <span class="signature-returns"> (number or <a href="module-la.Vector.html">module:la.Vector</a>)</span></span></h3> <p>Calculates the standard deviation(s).</p> <section> <h4> Example </h4> <div> <pre class="prettyprint"><code>// import modules var qm &#x3D; require(&#x27;qminer&#x27;); var la &#x3D; qm.la; var statistics &#x3D; qm.statistics; // create a matrix var mat &#x3D; new la.Matrix([[1, 2, 1], [-1, 2, -1], [3, 2, 3]]); // calculate the standard deviation of the matrix columns var mean &#x3D; statistics.std(mat);</code></pre> </div> </section> <section> <h4>Parameters</h4> <table class="jsdoc-details-table"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Optional</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td> <p>X</p> </td> <td> <p>(<a href="module-la.Vector.html">module:la.Vector</a> or <a href="module-la.Matrix.html">module:la.Matrix</a>)</p> </td> <td> <p>&nbsp;</p> </td> <td> <p>The input the method is used on.</p> </td> </tr> <tr> <td> <p>flag</p> </td> <td> <p>number</p> </td> <td> <p>Yes</p> </td> <td> <p>If set to to 0, it normalizes X by n-1; If set to 1 to, it normalizes by n.</p> <p>Defaults to <code>0</code>.</p> </td> </tr> <tr> <td> <p>dim</p> </td> <td> <p>number</p> </td> <td> <p>Yes</p> </td> <td> <p>Computes the standard deviations along the dimension of X specified by parameter <code>dim</code>. If set to 1, calculates the column standard deviation. If set to 2, calculates the row standard deviation.</p> <p>Defaults to <code>1</code>.</p> </td> </tr> </tbody> </table> </section> <dl class="dl-compact"> <dt>Returns</dt> <dd> <p><code>(number or <a href="module-la.Vector.html">module:la.Vector</a>)</code>B <br>1. If X is <a href="module-la.Vector.html">module:la.Vector</a>, returns standard deviation of the vector. <br>2. If X is <a href="module-la.Matrix.html">module:la.Matrix</a>, returns a vector where the i-th value is the standard deviation of the i-th column(row). </p> </dd> </dl> <div class="symbol-detail-labels"><span class="label label-static">static</span></div> <h3 id=".zscore"><span class="symbol-name">zscore</span><span class="signature"><span class="signature-params">(mat[, flag][, dim])</span>&nbsp;&rarr; <span class="signature-returns"> Object</span></span></h3> <p>Returns an object containing the standard deviation of each column of matrix, mean vector and z-score matrix.</p> <section> <h4> Example </h4> <div> <pre class="prettyprint"><code>// import modules var qm &#x3D; require(&#x27;qminer&#x27;); var la &#x3D; qm.la; var statistics &#x3D; qm.statistics; // create a matrix var mat &#x3D; new la.Matrix([[1, 2, 1], [-1, 2, -1], [3, 2, 3]]); // calculate the standard deviation of the matrix columns var mean &#x3D; statistics.zscore(mat);</code></pre> </div> </section> <section> <h4>Parameters</h4> <table class="jsdoc-details-table"> <thead> <tr> <th>Name</th> <th>Type</th> <th>Optional</th> <th>Description</th> </tr> </thead> <tbody> <tr> <td> <p>mat</p> </td> <td> <p><a href="module-la.Matrix.html">module:la.Matrix</a></p> </td> <td> <p>&nbsp;</p> </td> <td> <p>The matrix.</p> </td> </tr> <tr> <td> <p>flag</p> </td> <td> <p>number</p> </td> <td> <p>Yes</p> </td> <td> <p>If set to 0, it normalizes mat by n-1; if set to 1, it normalizes by n.</p> <p>Defaults to <code>0</code>.</p> </td> </tr> <tr> <td> <p>dim</p> </td> <td> <p>number</p> </td> <td> <p>Yes</p> </td> <td> <p>Computes the standard deviations along the dimension of mat specified by parameter <code>dim</code>. If set to 1, calculates the column standard deviation. If set to 2, calculates the row standard deviation.</p> <p>Defaults to <code>1</code>.</p> </td> </tr> </tbody> </table> </section> <dl class="dl-compact"> <dt>Returns</dt> <dd> <p><code>Object</code>B The object <code>zscoreResult</code> containing: <br><code>zscoreResult.sigma</code> - <a href="module-la.Vector.html">module:la.Vector</a> of standard deviations of mat used to compute the z-scores. <br><code>zscoreResult.mu</code> - <a href="module-la.Vector.html">module:la.Vector</a> of mean values of mat used to compute the z-scores. <br><code>zscoreResult.Z</code> - <a href="module-la.Matrix.html">module:la.Matrix</a> of z-scores that has mean 0 and variance 1. </p> </dd> </dl> </section> </section> </div> </div> <nav id="jsdoc-toc-nav" role="navigation"></nav> </div> </div> <footer id="jsdoc-footer" class="jsdoc-footer"> <div id="jsdoc-footer-container"> <p> </p> </div> </footer> <script src="scripts/jquery.min.js"></script> <script src="scripts/tree.jquery.js"></script> <script src="scripts/prettify.js"></script> <script src="scripts/jsdoc-toc.js"></script> <script src="scripts/linenumber.js"></script> <script src="scripts/scrollanchor.js"></script> </body> </html>