Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > b38d2da330d1936e5ab1307c039c4941 > files > 116

octave-doc-3.6.4-3.mga4.noarch.rpm

<html lang="en">
<head>
<title>Basic Statistical Functions - GNU Octave</title>
<meta http-equiv="Content-Type" content="text/html">
<meta name="description" content="GNU Octave">
<meta name="generator" content="makeinfo 4.13">
<link title="Top" rel="start" href="index.html#Top">
<link rel="up" href="Statistics.html#Statistics" title="Statistics">
<link rel="prev" href="Descriptive-Statistics.html#Descriptive-Statistics" title="Descriptive Statistics">
<link rel="next" href="Statistical-Plots.html#Statistical-Plots" title="Statistical Plots">
<link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
<meta http-equiv="Content-Style-Type" content="text/css">
<style type="text/css"><!--
  pre.display { font-family:inherit }
  pre.format  { font-family:inherit }
  pre.smalldisplay { font-family:inherit; font-size:smaller }
  pre.smallformat  { font-family:inherit; font-size:smaller }
  pre.smallexample { font-size:smaller }
  pre.smalllisp    { font-size:smaller }
  span.sc    { font-variant:small-caps }
  span.roman { font-family:serif; font-weight:normal; } 
  span.sansserif { font-family:sans-serif; font-weight:normal; } 
--></style>
</head>
<body>
<div class="node">
<a name="Basic-Statistical-Functions"></a>
<p>
Next:&nbsp;<a rel="next" accesskey="n" href="Statistical-Plots.html#Statistical-Plots">Statistical Plots</a>,
Previous:&nbsp;<a rel="previous" accesskey="p" href="Descriptive-Statistics.html#Descriptive-Statistics">Descriptive Statistics</a>,
Up:&nbsp;<a rel="up" accesskey="u" href="Statistics.html#Statistics">Statistics</a>
<hr>
</div>

<h3 class="section">26.2 Basic Statistical Functions</h3>

<p>Octave supports various helpful statistical functions.  Many are useful as
initial steps to prepare a data set for further analysis.  Others provide
different measures from those of the basic descriptive statistics.

<!-- center scripts/statistics/base/center.m -->
   <p><a name="doc_002dcenter"></a>

<div class="defun">
&mdash; Function File:  <b>center</b> (<var>x</var>)<var><a name="index-center-2445"></a></var><br>
&mdash; Function File:  <b>center</b> (<var>x, dim</var>)<var><a name="index-center-2446"></a></var><br>
<blockquote><p>If <var>x</var> is a vector, subtract its mean. 
If <var>x</var> is a matrix, do the above for each column. 
If the optional argument <var>dim</var> is given, operate along this dimension. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002dzscore.html#doc_002dzscore">zscore</a>. 
</p></blockquote></div>

<!-- zscore scripts/statistics/base/zscore.m -->
   <p><a name="doc_002dzscore"></a>

<div class="defun">
&mdash; Function File:  <b>zscore</b> (<var>x</var>)<var><a name="index-zscore-2447"></a></var><br>
&mdash; Function File:  <b>zscore</b> (<var>x, dim</var>)<var><a name="index-zscore-2448"></a></var><br>
<blockquote><p>If <var>x</var> is a vector, subtract its mean and divide by its standard
deviation.

        <p>If <var>x</var> is a matrix, do the above along the first non-singleton
dimension. 
If the optional argument <var>dim</var> is given, operate along this dimension. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002dcenter.html#doc_002dcenter">center</a>. 
</p></blockquote></div>

<!-- histc scripts/statistics/base/histc.m -->
   <p><a name="doc_002dhistc"></a>

<div class="defun">
&mdash; Function File: <var>n</var> = <b>histc</b> (<var>x, edges</var>)<var><a name="index-histc-2449"></a></var><br>
&mdash; Function File: <var>n</var> = <b>histc</b> (<var>x, edges, dim</var>)<var><a name="index-histc-2450"></a></var><br>
&mdash; Function File: [<var>n</var>, <var>idx</var>] = <b>histc</b> (<var><small class="dots">...</small></var>)<var><a name="index-histc-2451"></a></var><br>
<blockquote><p>Produce histogram counts.

        <p>When <var>x</var> is a vector, the function counts the number of elements of
<var>x</var> that fall in the histogram bins defined by <var>edges</var>.  This must be
a vector of monotonically increasing values that define the edges of the
histogram bins.  <var>n</var><code>(k)</code> contains the number of elements in
<var>x</var> for which <var>edges</var><code>(k) &lt;= </code><var>x</var><code> &lt; </code><var>edges</var><code>(k+1)</code>. 
The final element of <var>n</var> contains the number of elements of <var>x</var>
exactly equal to the last element of <var>edges</var>.

        <p>When <var>x</var> is an N-dimensional array, the computation is
carried out along dimension <var>dim</var>.  If not specified <var>dim</var> defaults
to the first non-singleton dimension.

        <p>When a second output argument is requested an index matrix is also returned. 
The <var>idx</var> matrix has the same size as <var>x</var>.  Each element of <var>idx</var>
contains the index of the histogram bin in which the corresponding element
of <var>x</var> was counted. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002dhist.html#doc_002dhist">hist</a>. 
</p></blockquote></div>

<!-- FIXME: really want to put a reference to unique here -->
<!-- @DOCSTRING(values) -->
<!-- nchoosek scripts/specfun/nchoosek.m -->
   <p><a name="doc_002dnchoosek"></a>

<div class="defun">
&mdash; Function File: <var>c</var> = <b>nchoosek</b> (<var>n, k</var>)<var><a name="index-nchoosek-2452"></a></var><br>
&mdash; Function File: <var>c</var> = <b>nchoosek</b> (<var>set, k</var>)<var><a name="index-nchoosek-2453"></a></var><br>
<blockquote>
        <p>Compute the binomial coefficient or all combinations of a set of items.

        <p>If <var>n</var> is a scalar then calculate the binomial coefficient
of <var>n</var> and <var>k</var> which is defined as

     <pre class="example">           /   \
           | n |    n (n-1) (n-2) ... (n-k+1)       n!
           |   |  = ------------------------- =  ---------
           | k |               k!                k! (n-k)!
           \   /
</pre>
        <p class="noindent">This is the number of combinations of <var>n</var> items taken in groups of
size <var>k</var>.

        <p>If the first argument is a vector, <var>set</var>, then generate all
combinations of the elements of <var>set</var>, taken <var>k</var> at a time, with
one row per combination.  The result <var>c</var> has <var>k</var> columns and
<code>nchoosek&nbsp;(length&nbsp;(</code><var>set</var><code>),&nbsp;</code><var>k</var><code>)</code><!-- /@w --> rows.

        <p>For example:

        <p>How many ways can three items be grouped into pairs?

     <pre class="example">          nchoosek (3, 2)
             &rArr; 3
</pre>
        <p>What are the possible pairs?

     <pre class="example">          nchoosek (1:3, 2)
             &rArr;  1   2
                 1   3
                 2   3
</pre>
        <p><code>nchoosek</code> works only for non-negative, integer arguments.  Use
<code>bincoeff</code> for non-integer and negative scalar arguments, or for
computing many binomial coefficients at once with vector inputs
for <var>n</var> or <var>k</var>.

     <!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
     <!-- A simple blank line produces the correct behavior. -->
     <!-- @sp 1 -->
     <p class="noindent"><strong>See also:</strong> <a href="doc_002dbincoeff.html#doc_002dbincoeff">bincoeff</a>, <a href="doc_002dperms.html#doc_002dperms">perms</a>. 
</p></blockquote></div>

<!-- perms scripts/specfun/perms.m -->
   <p><a name="doc_002dperms"></a>

<div class="defun">
&mdash; Function File:  <b>perms</b> (<var>v</var>)<var><a name="index-perms-2454"></a></var><br>
<blockquote>
        <p>Generate all permutations of <var>v</var>, one row per permutation.  The
result has size <code>factorial (</code><var>n</var><code>) * </code><var>n</var>, where <var>n</var>
is the length of <var>v</var>.

        <p>As an example, <code>perms([1, 2, 3])</code> returns the matrix

     <pre class="example">            1   2   3
            2   1   3
            1   3   2
            2   3   1
            3   1   2
            3   2   1
</pre>
        </blockquote></div>

<!-- ranks scripts/statistics/base/ranks.m -->
   <p><a name="doc_002dranks"></a>

<div class="defun">
&mdash; Function File:  <b>ranks</b> (<var>x, dim</var>)<var><a name="index-ranks-2455"></a></var><br>
<blockquote><p>Return the ranks of <var>x</var> along the first non-singleton dimension
adjusted for ties.  If the optional argument <var>dim</var> is
given, operate along this dimension. 
<!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
<!-- A simple blank line produces the correct behavior. -->
<!-- @sp 1 -->

     <p class="noindent"><strong>See also:</strong> <a href="doc_002dspearman.html#doc_002dspearman">spearman</a>, <a href="doc_002dkendall.html#doc_002dkendall">kendall</a>. 
</p></blockquote></div>

<!-- run_count scripts/statistics/base/run_count.m -->
   <p><a name="doc_002drun_005fcount"></a>

<div class="defun">
&mdash; Function File:  <b>run_count</b> (<var>x, n</var>)<var><a name="index-run_005fcount-2456"></a></var><br>
&mdash; Function File:  <b>run_count</b> (<var>x, n, dim</var>)<var><a name="index-run_005fcount-2457"></a></var><br>
<blockquote><p>Count the upward runs along the first non-singleton dimension of
<var>x</var> of length 1, 2, <small class="dots">...</small>, <var>n</var>-1 and greater than or equal
to <var>n</var>.

        <p>If the optional argument <var>dim</var> is given then operate
along this dimension. 
</p></blockquote></div>

<!-- runlength scripts/statistics/base/runlength.m -->
   <p><a name="doc_002drunlength"></a>

<div class="defun">
&mdash; Function File: [count, value] = <b>runlength</b> (<var>x</var>)<var><a name="index-runlength-2458"></a></var><br>
<blockquote><p>Find the lengths of all sequences of common values.  Return the
vector of lengths and the value that was repeated.

     <pre class="example">          runlength ([2, 2, 0, 4, 4, 4, 0, 1, 1, 1, 1])
          &rArr;  [2, 1, 3, 1, 4]
</pre>
        </blockquote></div>

<!-- probit scripts/statistics/base/probit.m -->
   <p><a name="doc_002dprobit"></a>

<div class="defun">
&mdash; Function File:  <b>probit</b> (<var>p</var>)<var><a name="index-probit-2459"></a></var><br>
<blockquote><p>For each component of <var>p</var>, return the probit (the quantile of the
standard normal distribution) of <var>p</var>. 
</p></blockquote></div>

<!-- logit scripts/statistics/base/logit.m -->
   <p><a name="doc_002dlogit"></a>

<div class="defun">
&mdash; Function File:  <b>logit</b> (<var>p</var>)<var><a name="index-logit-2460"></a></var><br>
<blockquote><p>For each component of <var>p</var>, return the logit of <var>p</var> defined as

     <pre class="example">          logit (<var>p</var>) = log (<var>p</var> / (1-<var>p</var>))
</pre>
        <!-- Texinfo @sp should work but in practice produces ugly results for HTML. -->
     <!-- A simple blank line produces the correct behavior. -->
     <!-- @sp 1 -->
     <p class="noindent"><strong>See also:</strong> <a href="doc_002dlogistic_005fcdf.html#doc_002dlogistic_005fcdf">logistic_cdf</a>. 
</p></blockquote></div>

<!-- cloglog scripts/statistics/base/cloglog.m -->
   <p><a name="doc_002dcloglog"></a>

<div class="defun">
&mdash; Function File:  <b>cloglog</b> (<var>x</var>)<var><a name="index-cloglog-2461"></a></var><br>
<blockquote><p>Return the complementary log-log function of <var>x</var>, defined as

     <pre class="example">          cloglog (x) = - log (- log (<var>x</var>))
</pre>
        </blockquote></div>

<!-- mahalanobis scripts/statistics/base/mahalanobis.m -->
   <p><a name="doc_002dmahalanobis"></a>

<div class="defun">
&mdash; Function File:  <b>mahalanobis</b> (<var>x, y</var>)<var><a name="index-mahalanobis-2462"></a></var><br>
<blockquote><p>Return the Mahalanobis' D-square distance between the multivariate
samples <var>x</var> and <var>y</var>, which must have the same number of
components (columns), but may have a different number of observations
(rows). 
</p></blockquote></div>

<!-- table scripts/statistics/base/table.m -->
   <p><a name="doc_002dtable"></a>

<div class="defun">
&mdash; Function File: [<var>t</var>, <var>l_x</var>] = <b>table</b> (<var>x</var>)<var><a name="index-table-2463"></a></var><br>
&mdash; Function File: [<var>t</var>, <var>l_x</var>, <var>l_y</var>] = <b>table</b> (<var>x, y</var>)<var><a name="index-table-2464"></a></var><br>
<blockquote><p>Create a contingency table <var>t</var> from data vectors.  The <var>l_x</var> and
<var>l_y</var> vectors are the corresponding levels.

        <p>Currently, only 1- and 2-dimensional tables are supported. 
</p></blockquote></div>

   </body></html>