public class DescriptiveStatistics
extends java.lang.Object
This class is meant to reproduce all the basic univariate statistics commonly found in statistics and many other statistical packages. Generally the form of this class will be similar to Apache's common Math package simply because this library started with those, therefore the transition will be much better if the same form (names, methods etc) are maintained. Nevertheless the form and the results (in terms of very late decimal points) might be very slightly(tiny) more different than common math.
This class will compute the following statistics :
1) Mean 2) Variance 3) Standard Deviation 4) Sum 5) Product 6) Min 7) Max 8) Count 9) Median 10) Quantiles 11) Percentiles 12) Skewness 13) Kurtosis 14) Range| Constructor and Description |
|---|
DescriptiveStatistics() |
| Modifier and Type | Method and Description |
|---|---|
void |
addArray(double[] array)
It adds the new double array' data to the existing instance of DescriptiveStatistics.
|
void |
addValue(double e)
This method feeds the DescriptiveStatistics with data needed for the calculations of all stats.
|
void |
clear()
Empties the contents of the DescriptiveStatistics arraylist
|
double |
getabsMax()
This method returns the absolute Max
|
double |
getabsMin()
This method returns the absolute Min
|
java.util.ArrayList<java.lang.Double> |
getArrayList()
This method returns all the elements of the DescriptiveStatistics as a double arraylist
|
double |
getDevSumsq()
Thus method returns the sum of deviations squares (also known as second moment) namely :
sumDevsquares = Ói=1(Xi=1-m)2
|
double[] |
getdoubleArray()
This method returns all the elements of the DescriptiveStatistics as a double array []
|
double |
getElement(int index)
A getter class for a specific index in the DescriptiveStatistics arraylist
|
double |
getKurtosis()
This method returns the kurtosis of the variable, same as SPSS does :
kurtosis = { [n(n+1)sum(xi - m)4- 3(n-1)3st.dev4] /[ st.dev4 (n-1)(n-2)(n-3)]}
|
double |
getMax()
This method returns the Max
|
double |
getMean()
Returns the average or mean namely:
m=Ói=1xi / N
|
double |
getMedian(boolean sorted)
This method returns the median
|
double |
getMin()
This method returns the Min
|
long |
getN()
Returns the Count laballed as N
|
double |
getPercentile(double value,
boolean sorted)
This method returns the percentile given a provided double number.
|
double |
getProduct()
This method returns the Product as :
Sum=Ði=1xi
Warning as it may be too big on big sets.
|
double |
getQuantile1(boolean sorted)
This method returns the first Quantile (25%)
|
double |
getQuantile3(boolean sorted)
This method returns the thrid Quantile (75%)
|
double |
getRange()
Returns the range which stands for the MAX-MIN.
|
double |
getSkewness()
This method returns the kurtosis of the variable, same as many statistical packages do :
skewness = [n / (n -1) (n - 2)] sum[(xi- mean)3] / std3
|
double |
getStandardDeviation()
This method returns the Standard Deviation as :
St.Dev=Sqrt(Ói=1(xi-m)2 / N)
|
double |
getSum()
This method returns the Sum as :
Sum=Ói=1xi
|
double |
getSumsq()
Thus method returns the sum of squares namely :
sumofsquares = Ói=1Xi=12
|
double |
getVariance()
This method returns the variance as :
var=Ói=1(xi-m)2 / N-1
|
void |
removeElement(int index)
This method removes an element from the current instance of DescriptiveStatistics
|
void |
setArray(double[] array)
It creates a new instance of DescriptiveStatistics and populates it with a double array.
|
public void addValue(double e)
This method feeds the DescriptiveStatistics with data needed for the calculations of all stats.
e - : a double valuepublic void clear()
Empties the contents of the DescriptiveStatistics arraylist
public void setArray(double[] array)
It creates a new instance of DescriptiveStatistics and populates it with a double array.
array - : a double array []public void addArray(double[] array)
It adds the new double array' data to the existing instance of DescriptiveStatistics.
array - : a double array []public double getElement(int index)
A getter class for a specific index in the DescriptiveStatistics arraylist
index - : the integer position of the value we want from the DescriptiveStatistics arraylistpublic void removeElement(int index)
This method removes an element from the current instance of DescriptiveStatistics
index - : the location of the value to be removedpublic java.util.ArrayList<java.lang.Double> getArrayList()
This method returns all the elements of the DescriptiveStatistics as a double arraylist
public double[] getdoubleArray()
This method returns all the elements of the DescriptiveStatistics as a double array []
public long getN()
Returns the Count laballed as N
public double getMean()
m=Ói=1xi / N
public double getVariance()
This method returns the variance as :
var=Ói=1(xi-m)2 / N-1
public double getStandardDeviation()
This method returns the Standard Deviation as :
St.Dev=Sqrt(Ói=1(xi-m)2 / N)
public double getSum()
This method returns the Sum as :
Sum=Ói=1xi
public double getSumsq()
Thus method returns the sum of squares namely :
sumofsquares = Ói=1Xi=12
public double getDevSumsq()
Thus method returns the sum of deviations squares (also known as second moment) namely :
sumDevsquares = Ói=1(Xi=1-m)2
public double getProduct()
This method returns the Product as :
Sum=Ði=1xiWarning as it may be too big on big sets.
public double getMax()
This method returns the Max
public double getMin()
This method returns the Min
public double getRange()
Returns the range which stands for the MAX-MIN.
public double getabsMax()
This method returns the absolute Max
public double getabsMin()
This method returns the absolute Min
public double getKurtosis()
This method returns the kurtosis of the variable, same as SPSS does :
kurtosis = { [n(n+1)sum(xi - m)4- 3(n-1)3st.dev4] /[ st.dev4 (n-1)(n-2)(n-3)]} public double getSkewness()
This method returns the kurtosis of the variable, same as many statistical packages do :
skewness = [n / (n -1) (n - 2)] sum[(xi- mean)3] / std3
public double getPercentile(double value,
boolean sorted)
This method returns the percentile given a provided double number. It would have made more sense to have the data already sorted prior to running this, however you will have the option to choose in the beginning on whether the data is sorted or not. Then this value is kept for future calculations, otherwise it needs to be re-specified
value - : a double value between 0 and 1 to reflect the desired percentagesorted - : a boolean flag on whether the data is sorted or not (false not sorted which is the default)public double getMedian(boolean sorted)
This method returns the median
sorted - : a boolean flag on whether the data is sorted or not (false not sorted which is the default)public double getQuantile1(boolean sorted)
This method returns the first Quantile (25%)
sorted - : a boolean flag on whether the data is sorted or not (false not sorted which is the default)public double getQuantile3(boolean sorted)
This method returns the thrid Quantile (75%)
sorted - : a boolean flag on whether the data is sorted or not (false not sorted which is the default)