skewness

Compute skewness values.

Syntax

s=skewness(X)

s=skewness(X,bc,dim)

Inputs

X
Data sample.
Type: double
Dimension: scalar | vector | matrix
bc
Bias correction flag, either 0 or 1 (default). Using [] also produces the default. See Comments.
Type: integer
Dimension: scalar
dim
Dimension on which to perform the calculation.
Default: first non-singleton dimension.
Type: integer
Dimension: scalar

Outputs

s
Skewness.

Examples

Vector example:

x=[9.3, 10.6, 11.9, 13.3, 15.1, 18.2];
s=skewness(x)
s = 0.47872
Matrix example:
x=[9.3, 4.8; 10.6, 6.6; 11.9, 8.0; 13.3, 9.3; 15.1, 10.6; 18.2, 11.9];
s=skewness(x, 0)
s = [Matrix] 1 x 2
0.65552  -0.20124

Comments

skewness(X, 1) = mean((X - mean (X)).^3) / (std(X, 1).^3)

skewness(X, 0) = sqrt(N*(N-1))/(N-2) * mean((X - mean (X)).^3) / (std(X, 1).^3)

Setting bc to 0 corrects the bias in the second and third moments.