Main Content

Skewness

returns the sample skewness of `y`

= skewness(`X`

)`X`

.

If

`X`

is a vector, then`skewness(X)`

returns a scalar value that is the skewness of the elements in`X`

.If

`X`

is a matrix, then`skewness(X)`

returns a row vector containing the sample skewness of each column in`X`

.If

`X`

is a multidimensional array, then`skewness(X)`

operates along the first nonsingleton dimension of`X`

.

specifies whether to correct for bias (`y`

= skewness(`X`

,`flag`

)`flag = 0`

) or not
(`flag = 1`

, the default). When `X`

represents a sample from a population, the skewness of `X`

is
biased, meaning it tends to differ from the population skewness by a systematic
amount based on the sample size. You can set `flag`

to
`0`

to correct for this systematic bias.

returns the skewness over the dimensions specified in the vector
`y`

= skewness(`X`

,`flag`

,`vecdim`

)`vecdim`

. For example, if `X`

is a 2-by-3-by-4
array, then `skewness(X,1,[1 2])`

returns a 1-by-1-by-4 array. Each
element of the output array is the biased skewness of the elements on the
corresponding page of `X`

.

Skewness is a measure of the asymmetry of the data around the sample mean. If skewness is negative, the data spreads out more to the left of the mean than to the right. If skewness is positive, the data spreads out more to the right. The skewness of the normal distribution (or any perfectly symmetric distribution) is zero.

The skewness of a distribution is defined as

$$s=\frac{E{\left(x-\mu \right)}^{3}}{{\sigma}^{3}},$$

where *µ* is the mean of *x*, *σ*
is the standard deviation of *x*, and
*E*(*t*) represents the expected value of the
quantity *t*. The `skewness`

function computes a
sample version of this population value.

When you set `flag`

to `1`

, the skewness is biased,
and the following equation applies:

$${s}_{1}=\frac{\frac{1}{n}{\displaystyle \sum _{i=1}^{n}{\left({x}_{i}-\overline{x}\right)}^{3}}}{{\left(\sqrt{\frac{1}{n}{\displaystyle \sum _{i=1}^{n}{\left({x}_{i}-\overline{x}\right)}^{2}}}\right)}^{3}}.$$

When you set `flag`

to `0`

,
`skewness`

corrects for the systematic bias, and the following
equation applies:

$${s}_{0}=\frac{\sqrt{n\left(n-1\right)}}{n-2}{s}_{1}.$$

This bias-corrected equation requires that `X`

contain at least three elements.