0 Replies - 1644 Views - Last Post: 05 April 2012 - 06:02 AM

#1 Ryano121   User is offline

  • D.I.C Lover
  • member icon

Reputation: 1461
  • View blog
  • Posts: 3,289
  • Joined: 30-January 11

Calculate an Unbiased Estimator of the Population Kurtosis

Posted 05 April 2012 - 06:02 AM

Description: See Example Usage in snippet.In probability theory and statistics, kurtosis is a measure of the shape of the probability distribution of a real-valued random variable. This method is used when the data represents the whole population and not just a sample of the population. The Excel function 'KURT' implements the population kurtosis
public class PopulationKurtosis
{
    // Returns the population kurtosis of a data set
    public static double populationKurtosis(double[] data)
    {
	double mean = mean(data);
	double standardDeviation = standardDeviation(data);
	double n = (double) data.length;

	double sum = 0;
	double multiplier = n * (n + 1) / ((n - 1) * (n - 2) * (n - 3));
	double subtractor = (3 * Math.pow(n - 1, 2)) / ((n - 2) * (n - 3));

	for (int i = 0; i < data.length; i++)
	{
	    sum += Math.pow((data[i] - mean) / standardDeviation, 4);
	}

	return multiplier * sum - subtractor;
    }
    
    // Returns the mean of a data set
    private static double mean(double[] data)
    {
	double sum = 0;
	
	for(int i = 0; i < data.length; i++)
	{
	    sum += data[i];
	}
	
	return sum  / data.length;
    }
    
    // Returns the sample standard deviation of a data set
    private static double standardDeviation(double[] data)
    {
	double mean = mean(data);

	double sumOfSquaredDeviations = 0;

	for (int i = 0; i < data.length; i++)
	{
	    sumOfSquaredDeviations += Math.pow(data[i] - mean, 2);
	}

	return Math.sqrt(sumOfSquaredDeviations / (data.length - 1));
    }

    public static void main(String[] args)
    {
	double[] x = { 2, 3, 4, 5, 6, 8, 10, 11.53542 };

	double result = PopulationKurtosis.populationKurtosis(x);
	System.out.println("Population Kurtosis = " + result);
    }
}

// OUTPUT

// Population Kurtosis = -1.0641818158866143


Is This A Good Question/Topic? 0
  • +

Page 1 of 1