Click or drag to resize

StatKurtosis Method (ReadOnlyDoubleMatrix, Boolean, DataOperation)

Returns the kurtosis of each row or column in the specified data, eventually adjusted for bias.

Namespace:  Novacta.Analytics
Assembly:  Novacta.Analytics (in Novacta.Analytics.dll) Version: 2.0.0
Syntax
public static DoubleMatrix Kurtosis(
	ReadOnlyDoubleMatrix data,
	bool adjustForBias,
	DataOperation dataOperation
)

Parameters

data
Type: Novacta.AnalyticsReadOnlyDoubleMatrix
The data.
adjustForBias
Type: SystemBoolean
If set to true signals that the kurtosis is adjusted for bias.
dataOperation
Type: Novacta.AnalyticsDataOperation
A constant to specify if the kurtosis is to be computed for rows or columns.

Return Value

Type: DoubleMatrix
The kurtosis of each row or column in the specified data, eventually adjusted for bias.
Exceptions
ExceptionCondition
ArgumentNullExceptiondata is null.
ArgumentExceptiondataOperation is not a field of DataOperation.
-or-
adjustForBias is true, dataOperation is OnRows and the number of columns of data is less than 4.
-or-
adjustForBias is true, dataOperation is OnColumns and the data number of rows is less than 4.
Remarks

The kurtosis of a random variable LaTeX equation can be defined as follows:

LaTeX equation

where LaTeX equation and LaTeX equation are the cumulants of order 2 and 4, respectively, and

LaTeX equation

is the LaTeX equation central moment of order LaTeX equation.

By interpreting the rows or the columns of data as samples drawn from random variables, this method returns the kurtosis estimates of such variables. Let LaTeX equation and LaTeX equation be the data number of rows and columns, respectively, and define

LaTeX equation

Operating on rows

If dataOperation is OnRows, then the method returns a column vector whose length equals the number of rows of data. The i-th entry of such column returns the kurtosis of the i-th data row, say LaTeX equation

The LaTeX equation parameter can be estimated through the coefficient

LaTeX equation

where

LaTeX equation

is the sample LaTeX equation-th central moment of the i-th row.

Note that LaTeX equation is undefined if the standard deviation of the i-th row of data is zero.

The statistic LaTeX equation is a biased estimator of LaTeX equation However, provided that the number of columns in data is greater than 3, it can be corrected for bias and the corresponding kurtosis evaluated through the coefficient

LaTeX equation

If adjustForBias is set to false, then LaTeX equation is estimated through LaTeX equation if it is defined, otherwise the i-th position in the returned value evaluates to NaN.

If adjustForBias is set to true, then this method operates as follows.

  • If LaTeX equation is less than 4, i.e. the cumulant estimators cannot be corrected for bias, then an exception is thrown.
  • Differently, if LaTeX equation is defined, then LaTeX equation is stored in the i-th position of the returned value, otherwise such position stores NaN.

Operating on columns

If dataOperation is OnColumns, then the method returns a row vector whose length is the data number of columns. The j-th entry of the returned row exposes the kurtosis of the j-th data column, say LaTeX equation

The LaTeX equation parameter can be estimated through the coefficient

LaTeX equation

where

LaTeX equation

is the sample LaTeX equation-th central moment of the j-th column.

Note that LaTeX equation is undefined if the standard deviation of the j-th column of data is zero.

The statistic LaTeX equation is a biased estimator of LaTeX equation. However, provided that the number of rows in data is greater than 3, it can be corrected for bias and the corresponding kurtosis evaluated through the coefficient

LaTeX equation

If adjustForBias is set to false, then LaTeX equation is estimated through LaTeX equation if it is defined, otherwise the j-th position in the returned value evaluates to NaN.

If adjustForBias is set to true, then this method operates as follows.

  • If LaTeX equation is less than 4, i.e. the cumulant estimators cannot be corrected for bias, then an exception is thrown.
  • Differently, if LaTeX equation is defined, then LaTeX equation is stored in the j-th position of the returned value, otherwise such position stores NaN.

Examples

In the following example, row and column kurtosis estimates in a data matrix are computed.

C#
using System;

namespace Novacta.Analytics.CodeExamples
{
    public class KurtosisExample0  
    {
        public void Main()
        {
            // Create a matrix.
            var data = new double[20] {
                1, 2, -3,  6, -2,
                2, 2,  2,  0,  7,
               -3, 2,  3,  2,  9,
                5, 2,  7, -1, -4
            };
            var matrix = DoubleMatrix.Dense(4, 5, data, StorageOrder.RowMajor);
            Console.WriteLine("The data matrix:");
            Console.WriteLine(matrix);

            // Kurtosis can be adjusted for bias.
            bool adjustForBias = true;

            // Compute the kurtosis on columns.
            var kurtosisOnColumns = Stat.Kurtosis(matrix, adjustForBias, DataOperation.OnColumns);

            Console.WriteLine();
            Console.WriteLine("Kurtosis on columns:");
            Console.WriteLine(kurtosisOnColumns);

            // Kurtosis is overloaded to accept data as a read-only matrix:
            // compute the kurtosis on rows using a read-only wrapper of the data matrix.
            ReadOnlyDoubleMatrix readOnlyMatrix = matrix.AsReadOnly();
            var kurtosisOnRows = Stat.Kurtosis(readOnlyMatrix, adjustForBias, DataOperation.OnRows);

            Console.WriteLine();
            Console.WriteLine("Kurtosis on rows:");
            Console.WriteLine(kurtosisOnRows);
        }
    }
}

// Executing method Main() produces the following output:
// 
// The data matrix:
// 1                2                -3               6                -2               
// 2                2                2                0                7                
// -3               2                3                2                9                
// 5                2                7                -1               -4               
// 
// 
// 
// Kurtosis on columns:
// 1.16566634       NaN              1.2821471        0.757655955      -5.07072         
// 
// 
// 
// Kurtosis on rows:
// -0.22506045      
// 3.37802768       
// 1.9340679        
// -1.46435105      
// 

See Also