kurtosis

Syntax

kurtosis(X, [biased=true])

Arguments

X is a vector/matrix.

biased is a Boolean value indicating whether the result is biased. The default value is true, meaning the bias is not corrected.

Details

Return the kurtosis of X. The calculation skips NULL values.

The calculation uses the following formula when biased=true:

\(kurtosis(x) = \frac{\dfrac{1}{n} {\sum\limits_{i = 1}^{n} (x_i - \bar{x})^4}} {\left(\dfrac{1}{n} {\sum\limits_{i = 1}^{n} (x_i - \bar{x})^2}\right)^2}\)

If X is a matrix, calculate the skewness of each column of X and return a vector.

In version 1.30.9 and above, the function kurtosis also supports querying partitioned tables and distributed tables with bias correction.

Function kurtosis in DolphinDB returns a biased result by default (biased = true), while in pandas and Excel it is unbiased estimation, and the kurtosis value 3 of the normal distribution is subtracted.

Refer to the following example, you can make the kurtosis results of DolphinDB consistent with that of pandas and excel:

python
$ m = [1111, 323, 43, 51]
$ df = pandas.DataFrame(m)
$ y = df.kurt()
2.504252

dolphindb
$ m=matrix(1111 323 43 51)
$ kurtosis(m, false) - 3
2.5043

Examples

Please note that as the example below uses a random number generator, the result is slightly different each time it is executed.

$ x=norm(0, 1, 1000000);
$ kurtosis(x);
3.000249

$ x[0]=100;
$ kurtosis(x);
100.626722

$ m=matrix(1..10, 1 2 3 4 5 6 7 8 9 100);
$ m;

#0

#1

1

1

2

2

3

3

4

4

5

5

6

6

7

7

8

8

9

9

10

100

$ kurtosis(m);
[1.775757575757576,7.997552566718839]