kurtosis

Description

example

k = kurtosis(X) returns the sample kurtosis of X.

  • If X is a vector, then kurtosis(X) returns a scalar value that is the kurtosis of the elements in X.

  • If X is a matrix, then kurtosis(X) returns a row vector that contains the sample kurtosis of each column in X.

  • If X is a multidimensional array, then kurtosis(X) operates along the first nonsingleton dimension of X.

example

k = kurtosis(X,flag) specifies whether to correct for bias (flag is 0) or not (flag is 1, the default). When X represents a sample from a population, the kurtosis of X is biased, meaning it tends to differ from the population kurtosis by a systematic amount based on the sample size. You can set flag to 0 to correct for this systematic bias.

example

k = kurtosis(X,flag,'all') returns the kurtosis of all elements of X.

example

k = kurtosis(X,flag,dim) returns the kurtosis along the operating dimension dim of X.

example

k = kurtosis(X,flag,vecdim) returns the kurtosis over the dimensions specified in the vector vecdim. For example, if X is a 2-by-3-by-4 array, then kurtosis(X,1,[1 2]) returns a 1-by-1-by-4 array. Each element of the output array is the biased kurtosis of the elements on the corresponding page of X.

Examples

collapse all

Set the random seed for reproducibility of the results.

rng('default')

Generate a matrix with 5 rows and 4 columns.

X = randn(5,4)
X = 5×4

    0.5377   -1.3077   -1.3499   -0.2050
    1.8339   -0.4336    3.0349   -0.1241
   -2.2588    0.3426    0.7254    1.4897
    0.8622    3.5784   -0.0631    1.4090
    0.3188    2.7694    0.7147    1.4172

Find the sample kurtosis of X.

k = kurtosis(X)
k = 1×4

    2.7067    1.4069    2.3783    1.1759

k is a row vector containing the sample kurtosis of each column in X.

For an input vector, correct for bias in the calculation of kurtosis by specifying the flag input argument.

Set the random seed for reproducibility of the results.

rng('default') 

Generate a vector of length 10.

x = randn(10,1)
x = 10×1

    0.5377
    1.8339
   -2.2588
    0.8622
    0.3188
   -1.3077
   -0.4336
    0.3426
    3.5784
    2.7694

Find the biased kurtosis of x. By default, kurtosis sets the value of flag to 1 for computing the biased kurtosis.

k1 = kurtosis(x) % flag is 1 by default
k1 = 2.3121

Find the bias-corrected kurtosis of x by setting the value of flag to 0.

k2 = kurtosis(x,0) 
k2 = 2.7483

Find the kurtosis along different dimensions for a multidimensional array.

Set the random seed for reproducibility of the results.

rng('default') 

Create a 4-by-3-by-2 array of random numbers.

X = randn([4,3,2])
X = 
X(:,:,1) =

    0.5377    0.3188    3.5784
    1.8339   -1.3077    2.7694
   -2.2588   -0.4336   -1.3499
    0.8622    0.3426    3.0349


X(:,:,2) =

    0.7254   -0.1241    0.6715
   -0.0631    1.4897   -1.2075
    0.7147    1.4090    0.7172
   -0.2050    1.4172    1.6302

Find the kurtosis of X along the default dimension.

k1 = kurtosis(X)
k1 = 
k1(:,:,1) =

    2.1350    1.7060    2.2789


k1(:,:,2) =

    1.0542    2.3278    2.0996

By default, kurtosis operates along the first dimension of X whose size does not equal 1. In this case, this dimension is the first dimension of X. Therefore, k1 is a 1-by-3-by-2 array.

Find the biased kurtosis of X along the second dimension.

k2 = kurtosis(X,1,2)
k2 = 
k2(:,:,1) =

    1.5000
    1.5000
    1.5000
    1.5000


k2(:,:,2) =

    1.5000
    1.5000
    1.5000
    1.5000

k2 is a 4-by-1-by-2 array.

Find the biased kurtosis of X along the third dimension.

k3 = kurtosis(X,1,3)
k3 = 4×3

    1.0000    1.0000    1.0000
    1.0000    1.0000    1.0000
    1.0000    1.0000    1.0000
    1.0000    1.0000    1.0000

k3 is a 4-by-3 matrix.

Find the kurtosis over multiple dimensions by using the 'all' and vecdim input arguments.

Set the random seed for reproducibility of the results.

rng('default')

Create a 4-by-3-by-2 array of random numbers.

X = randn([4 3 2])
X = 
X(:,:,1) =

    0.5377    0.3188    3.5784
    1.8339   -1.3077    2.7694
   -2.2588   -0.4336   -1.3499
    0.8622    0.3426    3.0349


X(:,:,2) =

    0.7254   -0.1241    0.6715
   -0.0631    1.4897   -1.2075
    0.7147    1.4090    0.7172
   -0.2050    1.4172    1.6302

Find the biased kurtosis of X.

kall = kurtosis(X,1,'all')
kall = 2.8029

kall is the biased kurtosis of the entire input data set X.

Find the biased kurtosis of each page of X by specifying the first and second dimensions.

kpage = kurtosis(X,1,[1 2])
kpage = 
kpage(:,:,1) =

    1.9345


kpage(:,:,2) =

    2.5877

For example, kpage(1,1,2) is the biased kurtosis of the elements in X(:,:,2).

Find the biased kurtosis of the elements in each X(i,:,:) slice by specifying the second and third dimensions.

krow = kurtosis(X,1,[2 3])
krow = 4×1

    3.8457
    1.4306
    1.7094
    2.3378

For example, krow(3) is the biased kurtosis of the elements in X(3,:,:).

Input Arguments

collapse all

Input data that represents a sample from a population, specified as a vector, matrix, or multidimensional array.

  • If X is a vector, then kurtosis(X) returns a scalar value that is the kurtosis of the elements in X.

  • If X is a matrix, then kurtosis(X) returns a row vector that contains the sample kurtosis of each column in X.

  • If X is a multidimensional array, then kurtosis(X) operates along the first nonsingleton dimension of X.

To specify the operating dimension when X is a matrix or an array, use the dim input argument.

kurtosis treats NaN values in X as missing values and removes them.

Data Types: single | double

Indicator for the bias, specified as 0 or 1.

  • If flag is 1 (default), then the kurtosis of X is biased, meaning it tends to differ from the population kurtosis by a systematic amount based on the sample size.

  • If flag is 0, then kurtosis corrects for the systematic bias.

Data Types: single | double | logical

Dimension along which to operate, specified as a positive integer. If you do not specify a value for dim, then the default is the first dimension of X whose size does not equal 1.

Consider the kurtosis of a matrix X:

  • If dim is equal to 1, then kurtosis returns a row vector that contains the sample kurtosis of each column in X.

  • If dim is equal to 2, then kurtosis returns a column vector that contains the sample kurtosis of each row in X.

If dim is greater than ndims(X) or if size(X,dim) is 1, then kurtosis returns an array of NaNs the same size as X.

Data Types: single | double

Vector of dimensions, specified as a positive integer vector. Each element of vecdim represents a dimension of the input array X. The output k has length 1 in the specified operating dimensions. The other dimension lengths are the same for X and k.

For example, if X is a 2-by-3-by-3 array, then kurtosis(X,1,[1 2]) returns a 1-by-1-by-3 array. Each element of the output is the biased kurtosis of the elements on the corresponding page of X.

Data Types: single | double

Output Arguments

collapse all

Kurtosis, returned as a scalar, vector, matrix, or multidimensional array.

Algorithms

Kurtosis is a measure of how outlier-prone a distribution is. The kurtosis of the normal distribution is 3. Distributions that are more outlier-prone than the normal distribution have kurtosis greater than 3; distributions that are less outlier-prone have kurtosis less than 3. Some definitions of kurtosis subtract 3 from the computed value, so that the normal distribution has kurtosis of 0. The kurtosis function does not use this convention.

The kurtosis of a distribution is defined as

k=E(xμ)4σ4,

where μ is the mean of x, σ is the standard deviation of x, and E(t) represents the expected value of the quantity t. The kurtosis function computes a sample version of this population value.

When you set flag to 1, the kurtosis is biased, and the following equation applies:

k1=1ni=1n(xix¯)4(1ni=1n(xix¯)2)2.

When you set flag to 0, kurtosis corrects for the systematic bias, and the following equation applies:

k0=n1(n2)(n3)((n+1)k13(n1))+3.

This bias-corrected equation requires that X contain at least four elements.

Extended Capabilities

Introduced before R2006a