Next: Statistical Plots, Previous: Descriptive Statistics, Up: Statistics [Contents][Index]

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.

- Function File:
**center***(*`x`) - Function File:
**center***(*`x`,`dim`) If

`x`is a vector, subtract its mean. If`x`is a matrix, do the above for each column. If the optional argument`dim`is given, operate along this dimension.**See also:**zscore.

- Function File:
*[*`z`,`mu`,`sigma`] =**zscore***(*`x`) - Function File:
*[*`z`,`mu`,`sigma`] =**zscore***(*`x`,`opt`) - Function File:
*[*`z`,`mu`,`sigma`] =**zscore***(*`x`,`opt`,`dim`) If

`x`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`opt`determines the normalization to use when computing the standard deviation and is the same as the corresponding parameter for`std`

.If

`x`is a matrix, do the above along the first non-singleton dimension. If the third optional argument`dim`is given, operate along this dimension.The mean and standard deviation along

`dim`are given in`mu`and`sigma`respectively.

- Function File:
`n`=**histc***(*`x`,`edges`) - Function File:
`n`=**histc***(*`x`,`edges`,`dim`) - Function File:
*[*`n`,`idx`] =**histc***(…)* Produce histogram counts.

When

`x`is a vector, the function counts the number of elements of`x`that fall in the histogram bins defined by`edges`. This must be a vector of monotonically increasing values that define the edges of the histogram bins.

contains the number of elements in`n`(k)`x`for which

. The final element of`edges`(k) <=`x`<`edges`(k+1)`n`contains the number of elements of`x`exactly equal to the last element of`edges`.When

`x`is an*N*-dimensional array, the computation is carried out along dimension`dim`. If not specified`dim`defaults to the first non-singleton dimension.When a second output argument is requested an index matrix is also returned. The

`idx`matrix has the same size as`x`. Each element of`idx`contains the index of the histogram bin in which the corresponding element of`x`was counted.**See also:**hist.

- Function File:
`c`=**nchoosek***(*`n`,`k`) - Function File:
`c`=**nchoosek***(*`set`,`k`) -
Compute the binomial coefficient or all combinations of a set of items.

If

`n`is a scalar then calculate the binomial coefficient of`n`and`k`which is defined as/ \ | n | n (n-1) (n-2) … (n-k+1) n! | | = ------------------------- = --------- | k | k! k! (n-k)! \ /

This is the number of combinations of

`n`items taken in groups of size`k`.If the first argument is a vector,

`set`, then generate all combinations of the elements of`set`, taken`k`at a time, with one row per combination. The result`c`has`k`columns and`nchoosek (length (`

rows.`set`),`k`)For example:

How many ways can three items be grouped into pairs?

nchoosek (3, 2) ⇒ 3

What are the possible pairs?

nchoosek (1:3, 2) ⇒ 1 2 1 3 2 3

`nchoosek`

works only for non-negative, integer arguments. Use`bincoeff`

for non-integer and negative scalar arguments, or for computing many binomial coefficients at once with vector inputs for`n`or`k`.

- Function File:
**perms***(*`v`) -
Generate all permutations of

`v`, one row per permutation. The result has size`factorial (`

, where`n`) *`n``n`is the length of`v`.As an example,

`perms ([1, 2, 3])`

returns the matrix1 2 3 2 1 3 1 3 2 2 3 1 3 1 2 3 2 1

- Function File:
**ranks***(*`x`,`dim`) Return the ranks of

`x`along the first non-singleton dimension adjusted for ties. If the optional argument`dim`is given, operate along this dimension.

- Function File:
**run_count***(*`x`,`n`) - Function File:
**run_count***(*`x`,`n`,`dim`) Count the upward runs along the first non-singleton dimension of

`x`of length 1, 2, …,`n`-1 and greater than or equal to`n`.If the optional argument

`dim`is given then operate along this dimension.

- Function File:
*[count, value] =***runlength***(*`x`) Find the lengths of all sequences of common values. Return the vector of lengths and the value that was repeated.

runlength ([2, 2, 0, 4, 4, 4, 0, 1, 1, 1, 1]) ⇒ [2, 1, 3, 1, 4]

- Function File:
**probit***(*`p`) For each component of

`p`, return the probit (the quantile of the standard normal distribution) of`p`.

- Function File:
**logit***(*`p`) For each component of

`p`, return the logit of`p`defined aslogit (

`p`) = log (`p`/ (1-`p`))**See also:**logistic_cdf.

- Function File:
**cloglog***(*`x`) Return the complementary log-log function of

`x`, defined ascloglog (x) = - log (- log (

`x`))

- Function File:
**mahalanobis***(*`x`,`y`) Return the Mahalanobis’ D-square distance between the multivariate samples

`x`and`y`, which must have the same number of components (columns), but may have a different number of observations (rows).

- Function File:
*[*`t`,`l_x`] =**table***(*`x`) - Function File:
*[*`t`,`l_x`,`l_y`] =**table***(*`x`,`y`) Create a contingency table

`t`from data vectors. The`l_x`and`l_y`vectors are the corresponding levels.Currently, only 1- and 2-dimensional tables are supported.

Next: Statistical Plots, Previous: Descriptive Statistics, Up: Statistics [Contents][Index]