Package dev.nm.stat.descriptive.moment
Class Skewness
- java.lang.Object
-
- dev.nm.stat.descriptive.moment.Skewness
-
- All Implemented Interfaces:
Statistic
public class Skewness extends Object implements Statistic
Skewness is a measure of the asymmetry of the probability distribution. A distribution may either be positively or negatively skewed. For positive skew (or right-skewed), the right tail is longer. The mass of the distribution is concentrated on the left. For negative skew (or left-skewed), the left tail is longer. The mass of the distribution is concentrated on the right. The definition is:γ = E[((X - E(X)) / σ)3]
This implementation uses Chan's update formula to incrementally compute the new statistic. The R equivalent function isskewness
.- See Also:
- Wikipedia: Skewness
- Wikipedia: Algorithms for calculating variance
- "Chan, Tony F.; Golub, Gene H.; LeVeque, Randall J. (1979), "Updating Formulae and a Pairwise Algorithm for Computing Sample Variances," Technical Report STAN-CS-79-773, Department of Computer Science, Stanford University."
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addData(double... data)
Recompute the statistic with more data, incrementally if possible.double
mean()
Get the sample mean.long
N()
Get the size of the sample.double
sample()
Get the sample skewness (biased estimator).String
toString()
double
value()
Get the value of the statistic.double
variance()
Get the (unbiased) variance.
-
-
-
Constructor Detail
-
Skewness
public Skewness()
Construct an emptySkewness
calculator.
-
Skewness
public Skewness(double[] data)
Construct aSkewness
calculator, initialized with a sample.- Parameters:
data
- a sample
-
Skewness
public Skewness(Skewness that)
Copy constructor.- Parameters:
that
- aSkewness
calculator
-
-
Method Detail
-
sample
public double sample()
Get the sample skewness (biased estimator).- Returns:
- the sample skewness
-
mean
public double mean()
Get the sample mean.- Returns:
- the mean
-
variance
public double variance()
Get the (unbiased) variance.- Returns:
- the (unbiased) variance
-
addData
public void addData(double... data)
Description copied from interface:Statistic
Recompute the statistic with more data, incrementally if possible.
-
value
public double value()
Description copied from interface:Statistic
Get the value of the statistic.
-
N
public long N()
Description copied from interface:Statistic
Get the size of the sample.
-
-