Example: Summary Statistics
Summary statistics for a small data set are computed.
import com.imsl.stat.*;
public class SummaryEx1 {
static final double data1[] = {3, 6.4, 2, 1.6, -8, 12, -7,
6.4, 22, 1, 0, -3.2};
public static void main(String args[]) {
Summary summary = new Summary();
summary.update(data1);
System.out.println("The minimum is "+summary.getMinimum());
System.out.println();
System.out.println("The maximum is "+summary.getMaximum());
System.out.println();
System.out.println("The mean is "+summary.getMean());
System.out.println();
System.out.println("The variance is "+summary.getVariance());
System.out.println();
System.out.println("The sample variance is " +
summary.getSampleVariance());
System.out.println();
System.out.println("The standard deviation is " +
summary.getStandardDeviation());
System.out.println();
System.out.println("The skewness is "+summary.getSkewness());
System.out.println();
System.out.println("The kurtosis is "+summary.getKurtosis());
System.out.println();
double confmn[] = new double[2];
confmn = summary.confidenceMean(0.95);
System.out.println("The confidence Mean is {" + confmn[0] +
", " + confmn[1]+"}");
System.out.println();
double confvr[] = new double[2];
confvr = summary.confidenceVariance(0.95);
System.out.println("The confidence Variance is {" + confvr[0] +
", " + confvr[1]+"}");
}
}
Output
The minimum is -8.0
The maximum is 22.0
The mean is 3.016666666666666
The variance is 61.70972222222223
The sample variance is 67.31969696969698
The standard deviation is 7.855553591073148
The skewness is 0.8632224134285833
The kurtosis is 0.5677060483851211
The confidence Mean is {-2.1964514686012353, 8.229784801934567}
The confidence Variance is {33.78261872720627, 194.0685332772439}
Link to Java source.