# Calculate an Unbiased Estimator of the Population Skewness

Page 1 of 1

## 0 Replies - 1628 Views - Last Post: 04 April 2012 - 04:31 AM

### #1 Ryano121

• D.I.C Lover

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

# Calculate an Unbiased Estimator of the Population Skewness

Posted 04 April 2012 - 04:31 AM

Description: See Example Usage in snippetIn probability theory and statistics, skewness is a measure of the asymmetry of the probability distribution of a real-valued random variable. The population skewness is calculated when the data is consists of the whole population and not just a sample of the population. The Excel function 'SKEW' calculates the population skewness.
```public class PopulationSkewness
{
// Returns the population skewness of a data set
public static double skewness(double[] data)
{
double mean = mean(data);
double stdDev = standardDeviation(data);

double n = (double) data.length;

// Calculate the initial multiplier
double multiplier = n / ((n - 1) * (n - 2));
double sum = 0;

for(int i = 0; i < data.length; i++)
{
// Sum the deviations over the standard deviation to the third power
sum += Math.pow((data[i] - mean) / stdDev, 3);
}

return multiplier * sum;
}

// 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 = PopulationSkewnesss.skewness(x);
System.out.println("Population Skewness = " + result);
}
}

//OUTPUT

// Population Skewness = 0.46676103087604776
```

Is This A Good Question/Topic? 0

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }