Click or drag to resize

StatKurtosis Method (ReadOnlyDoubleMatrix, Boolean)

Returns the kurtosis of the specified data, eventually adjusted for bias.

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

Parameters

data
Type: Novacta.AnalyticsReadOnlyDoubleMatrix
The data.
adjustForBias
Type: SystemBoolean
If set to true signals that the kurtosis is adjusted for bias.

Return Value

Type: Double
The kurtosis of the specified data, eventually adjusted for bias.
Exceptions
ExceptionCondition
ArgumentNullExceptiondata is null.
ArgumentExceptionadjustForBias is true and the number of entries in data 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.

The LaTeX equation parameter can be estimated through the coefficient

LaTeX equation

where

LaTeX equation

is the sample central moment of order LaTeX equation, LaTeX equation is the dataCount and

LaTeX equation

Note that LaTeX equation is undefined if the standard deviation of data is zero.

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

LaTeX equation

If adjustForBias is set to false, this method returns LaTeX equation if it is defined, otherwise NaN is returned.

If adjustForBias is set to true, then this methods 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 returned, otherwise the return value is NaN.

Examples

In the following example, the kurtosis of a data matrix is computed.

C#
using System;

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

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

            // Compute the data kurtosis.
            var kurtosis = Stat.Kurtosis(matrix, adjustForBias);

            Console.WriteLine();
            Console.WriteLine("Data kurtosis is:");
            Console.WriteLine(kurtosis);

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

            Console.WriteLine();
            Console.WriteLine("Using read-only data. The kurtosis is:");
            Console.WriteLine(kurtosisOfReadOnlyData);
        }
    }
}

// Executing method Main() produces the following output:
// 
// The data matrix:
// 1                2                
// 2                -3               
// 3                4                
// 
// 
// 
// Data kurtosis is:
// 0.1327204826199364
// 
// Using read-only data. The kurtosis is:
// 0.1327204826199364

See Also