1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
<head>
<title>GNU Octave: Basic Statistical Functions</title>
<meta name="description" content="GNU Octave: Basic Statistical Functions">
<meta name="keywords" content="GNU Octave: Basic Statistical Functions">
<meta name="resource-type" content="document">
<meta name="distribution" content="global">
<meta name="Generator" content="makeinfo">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="index.html#Top" rel="start" title="Top">
<link href="Concept-Index.html#Concept-Index" rel="index" title="Concept Index">
<link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
<link href="Statistics.html#Statistics" rel="up" title="Statistics">
<link href="Statistical-Plots.html#Statistical-Plots" rel="next" title="Statistical Plots">
<link href="Descriptive-Statistics.html#Descriptive-Statistics" rel="prev" title="Descriptive Statistics">
<style type="text/css">
<!--
a.summary-letter {text-decoration: none}
blockquote.smallquotation {font-size: smaller}
div.display {margin-left: 3.2em}
div.example {margin-left: 3.2em}
div.indentedblock {margin-left: 3.2em}
div.lisp {margin-left: 3.2em}
div.smalldisplay {margin-left: 3.2em}
div.smallexample {margin-left: 3.2em}
div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
div.smalllisp {margin-left: 3.2em}
kbd {font-style:oblique}
pre.display {font-family: inherit}
pre.format {font-family: inherit}
pre.menu-comment {font-family: serif}
pre.menu-preformatted {font-family: serif}
pre.smalldisplay {font-family: inherit; font-size: smaller}
pre.smallexample {font-size: smaller}
pre.smallformat {font-family: inherit; font-size: smaller}
pre.smalllisp {font-size: smaller}
span.nocodebreak {white-space:nowrap}
span.nolinebreak {white-space:nowrap}
span.roman {font-family:serif; font-weight:normal}
span.sansserif {font-family:sans-serif; font-weight:normal}
ul.no-bullet {list-style: none}
-->
</style>
</head>
<body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
<a name="Basic-Statistical-Functions"></a>
<div class="header">
<p>
Next: <a href="Statistical-Plots.html#Statistical-Plots" accesskey="n" rel="next">Statistical Plots</a>, Previous: <a href="Descriptive-Statistics.html#Descriptive-Statistics" accesskey="p" rel="prev">Descriptive Statistics</a>, Up: <a href="Statistics.html#Statistics" accesskey="u" rel="up">Statistics</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
<hr>
<a name="Basic-Statistical-Functions-1"></a>
<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.
</p>
<a name="XREFcenter"></a><dl>
<dt><a name="index-center"></a>Function File: <em></em> <strong>center</strong> <em>(<var>x</var>)</em></dt>
<dt><a name="index-center-1"></a>Function File: <em></em> <strong>center</strong> <em>(<var>x</var>, <var>dim</var>)</em></dt>
<dd><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.
</p>
<p><strong>See also:</strong> <a href="#XREFzscore">zscore</a>.
</p></dd></dl>
<a name="XREFzscore"></a><dl>
<dt><a name="index-zscore"></a>Function File: <em>[<var>z</var>, <var>mu</var>, <var>sigma</var>] =</em> <strong>zscore</strong> <em>(<var>x</var>)</em></dt>
<dt><a name="index-zscore-1"></a>Function File: <em>[<var>z</var>, <var>mu</var>, <var>sigma</var>] =</em> <strong>zscore</strong> <em>(<var>x</var>, <var>opt</var>)</em></dt>
<dt><a name="index-zscore-2"></a>Function File: <em>[<var>z</var>, <var>mu</var>, <var>sigma</var>] =</em> <strong>zscore</strong> <em>(<var>x</var>, <var>opt</var>, <var>dim</var>)</em></dt>
<dd><p>If <var>x</var> is a vector, subtract its mean and divide by its standard
deviation. If the standard deviation is zero, divide by 1 instead.
The optional parameter <var>opt</var> determines the normalization to use
when computing the standard deviation and is the same as the
corresponding parameter for <code>std</code>.
</p>
<p>If <var>x</var> is a matrix, do the above along the first non-singleton
dimension. If the third optional argument <var>dim</var> is given, operate
along this dimension.
</p>
<p>The mean and standard deviation along <var>dim</var> are given in <var>mu</var>
and <var>sigma</var> respectively.
</p>
<p><strong>See also:</strong> <a href="Descriptive-Statistics.html#XREFmean">mean</a>, <a href="Descriptive-Statistics.html#XREFstd">std</a>, <a href="#XREFcenter">center</a>.
</p></dd></dl>
<a name="XREFhistc"></a><dl>
<dt><a name="index-histc"></a>Function File: <em><var>n</var> =</em> <strong>histc</strong> <em>(<var>x</var>, <var>edges</var>)</em></dt>
<dt><a name="index-histc-1"></a>Function File: <em><var>n</var> =</em> <strong>histc</strong> <em>(<var>x</var>, <var>edges</var>, <var>dim</var>)</em></dt>
<dt><a name="index-histc-2"></a>Function File: <em>[<var>n</var>, <var>idx</var>] =</em> <strong>histc</strong> <em>(…)</em></dt>
<dd><p>Produce histogram counts.
</p>
<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. <code><var>n</var>(k)</code> contains the number of elements in
<var>x</var> for which <code><var>edges</var>(k) <= <var>x</var> < <var>edges</var>(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>
<p>When <var>x</var> is an <em>N</em>-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>
<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.
</p>
<p><strong>See also:</strong> <a href="Two_002dDimensional-Plots.html#XREFhist">hist</a>.
</p></dd></dl>
<a name="XREFnchoosek"></a><dl>
<dt><a name="index-nchoosek"></a>Function File: <em><var>c</var> =</em> <strong>nchoosek</strong> <em>(<var>n</var>, <var>k</var>)</em></dt>
<dt><a name="index-nchoosek-1"></a>Function File: <em><var>c</var> =</em> <strong>nchoosek</strong> <em>(<var>set</var>, <var>k</var>)</em></dt>
<dd>
<p>Compute the binomial coefficient or all combinations of a set of items.
</p>
<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
</p>
<div class="example">
<pre class="example"> / \
| n | n (n-1) (n-2) … (n-k+1) n!
| | = ------------------------- = ---------
| k | k! k! (n-k)!
\ /
</pre></div>
<p>This is the number of combinations of <var>n</var> items taken in groups of
size <var>k</var>.
</p>
<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 (length (<var>set</var>), <var>k</var>)</code><!-- /@w --> rows.
</p>
<p>For example:
</p>
<p>How many ways can three items be grouped into pairs?
</p>
<div class="example">
<pre class="example">nchoosek (3, 2)
⇒ 3
</pre></div>
<p>What are the possible pairs?
</p>
<div class="example">
<pre class="example">nchoosek (1:3, 2)
⇒ 1 2
1 3
2 3
</pre></div>
<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>.
</p>
<p><strong>See also:</strong> <a href="Special-Functions.html#XREFbincoeff">bincoeff</a>, <a href="#XREFperms">perms</a>.
</p></dd></dl>
<a name="XREFperms"></a><dl>
<dt><a name="index-perms"></a>Function File: <em></em> <strong>perms</strong> <em>(<var>v</var>)</em></dt>
<dd>
<p>Generate all permutations of <var>v</var>, one row per permutation. The
result has size <code>factorial (<var>n</var>) * <var>n</var></code>, where <var>n</var>
is the length of <var>v</var>.
</p>
<p>As an example, <code>perms ([1, 2, 3])</code> returns the matrix
</p>
<div class="example">
<pre class="example"> 1 2 3
2 1 3
1 3 2
2 3 1
3 1 2
3 2 1
</pre></div>
</dd></dl>
<a name="XREFranks"></a><dl>
<dt><a name="index-ranks"></a>Function File: <em></em> <strong>ranks</strong> <em>(<var>x</var>, <var>dim</var>)</em></dt>
<dd><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.
</p>
<p><strong>See also:</strong> <a href="Correlation-and-Regression-Analysis.html#XREFspearman">spearman</a>, <a href="Correlation-and-Regression-Analysis.html#XREFkendall">kendall</a>.
</p></dd></dl>
<a name="XREFrun_005fcount"></a><dl>
<dt><a name="index-run_005fcount"></a>Function File: <em></em> <strong>run_count</strong> <em>(<var>x</var>, <var>n</var>)</em></dt>
<dt><a name="index-run_005fcount-1"></a>Function File: <em></em> <strong>run_count</strong> <em>(<var>x</var>, <var>n</var>, <var>dim</var>)</em></dt>
<dd><p>Count the upward runs along the first non-singleton dimension of
<var>x</var> of length 1, 2, …, <var>n</var>-1 and greater than or equal
to <var>n</var>.
</p>
<p>If the optional argument <var>dim</var> is given then operate
along this dimension.
</p></dd></dl>
<a name="XREFrunlength"></a><dl>
<dt><a name="index-runlength"></a>Function File: <em>[count, value] =</em> <strong>runlength</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Find the lengths of all sequences of common values. Return the
vector of lengths and the value that was repeated.
</p>
<div class="example">
<pre class="example">runlength ([2, 2, 0, 4, 4, 4, 0, 1, 1, 1, 1])
⇒ [2, 1, 3, 1, 4]
</pre></div>
</dd></dl>
<a name="XREFprobit"></a><dl>
<dt><a name="index-probit"></a>Function File: <em></em> <strong>probit</strong> <em>(<var>p</var>)</em></dt>
<dd><p>For each component of <var>p</var>, return the probit (the quantile of the
standard normal distribution) of <var>p</var>.
</p></dd></dl>
<a name="XREFlogit"></a><dl>
<dt><a name="index-logit"></a>Function File: <em></em> <strong>logit</strong> <em>(<var>p</var>)</em></dt>
<dd><p>For each component of <var>p</var>, return the logit of <var>p</var> defined as
</p>
<div class="example">
<pre class="example">logit (<var>p</var>) = log (<var>p</var> / (1-<var>p</var>))
</pre></div>
<p><strong>See also:</strong> <a href="Distributions.html#XREFlogistic_005fcdf">logistic_cdf</a>.
</p></dd></dl>
<a name="XREFcloglog"></a><dl>
<dt><a name="index-cloglog"></a>Function File: <em></em> <strong>cloglog</strong> <em>(<var>x</var>)</em></dt>
<dd><p>Return the complementary log-log function of <var>x</var>, defined as
</p>
<div class="example">
<pre class="example">cloglog (x) = - log (- log (<var>x</var>))
</pre></div>
</dd></dl>
<a name="XREFmahalanobis"></a><dl>
<dt><a name="index-mahalanobis"></a>Function File: <em></em> <strong>mahalanobis</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dd><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></dd></dl>
<a name="XREFtable"></a><dl>
<dt><a name="index-table"></a>Function File: <em>[<var>t</var>, <var>l_x</var>] =</em> <strong>table</strong> <em>(<var>x</var>)</em></dt>
<dt><a name="index-table-1"></a>Function File: <em>[<var>t</var>, <var>l_x</var>, <var>l_y</var>] =</em> <strong>table</strong> <em>(<var>x</var>, <var>y</var>)</em></dt>
<dd><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>
<p>Currently, only 1- and 2-dimensional tables are supported.
</p></dd></dl>
<hr>
<div class="header">
<p>
Next: <a href="Statistical-Plots.html#Statistical-Plots" accesskey="n" rel="next">Statistical Plots</a>, Previous: <a href="Descriptive-Statistics.html#Descriptive-Statistics" accesskey="p" rel="prev">Descriptive Statistics</a>, Up: <a href="Statistics.html#Statistics" accesskey="u" rel="up">Statistics</a> [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="Concept-Index.html#Concept-Index" title="Index" rel="index">Index</a>]</p>
</div>
</body>
</html>
|