Documentation

skewness

Skewness

Syntax

y = skewness(X)
y = skewness(X,flag)
y = skewness(X,flag,dim)

Description

y = skewness(X)returns the sample skewness ofX. For vectors,skewness(x)is the skewness of the elements ofx. For matrices,skewness(X)is a row vector containing the sample skewness of each column. For N-dimensional arrays,skewnessoperates along the first nonsingleton dimension ofX.

y = skewness(X,flag)specifies whether to correct for bias (flag = 0) or not (flag = 1, the default). WhenXrepresents a sample from a population, the skewness ofXis biased; that is, it will tend to differ from the population skewness by a systematic amount that depends on the size of the sample. You can setflag = 0to correct for this systematic bias.

y = skewness(X,flag,dim)takes the skewness along dimensiondimofX.

skewnesstreatsNaNs as missing values and removes them.

Examples

X = randn([5 4]) X = 1.1650 1.6961 -1.4462 -0.3600 0.6268 0.0591 -0.7012 -0.1356 0.0751 1.7971 1.2460 -1.3493 0.3516 0.2641 -0.6390 -1.2704 -0.6965 0.8717 0.5774 0.9846 y = skewness(X) y = -0.2933 0.0482 0.2735 0.4641

Algorithms

Skewness is a measure of the asymmetry of the data around the sample mean. If skewness is negative, the data are spread out more to the left of the mean than to the right. If skewness is positive, the data are spread 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 = E ( x μ ) 3 σ 3

whereµis the mean ofx,σis the standard deviation ofx, andE(t) represents the expected value of the quantityt.skewnesscomputes a sample version of this population value.

When you setflagto 1, the following equation applies:

s 1 = 1 n i = 1 n ( x i x ¯ ) 3 ( 1 n i = 1 n ( x i x ¯ ) 2 ) 3

When you setflagto 0, the following equation applies:

s 0 = n ( n 1 ) n 2 s 1

This bias-corrected formula requires thatXcontain at least three elements.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

Introduced before R2006a

Was this topic helpful?