StatBean Name: SampleStatistics

Purpose: Computes sample statistics for the data in two or more numeric columns.

DataSource: any.

Read/Write Properties
NameTypeDescriptionPossible ValuesDefault Value
columnNamesString arrayThe names of the columns to be analyzed.One or more strings.{""}
missingValueExclusionStringThe method for handling records which contain missing values."Columnwise","Casewise",
"Tablewise"
"Columnwise"

Other Public Methods
NameDescriptionArgumentsReturn Value
double getCoefficientOfVariation(int columnNumber)Calculates the CV by dividing the sample standard deviation by the sample mean and multiplying by 100.Column number (0 origin).Coefficient of variation, or missingValueCode if n<1 or mean = 0.
double getGeometricMean(int columnNumber)Calculates the geometric mean.Column number (0 origin).Sample geometric mean, or missingValueCode if n=0 or any data value is <= 0.
double getInterquartileRange(int columnNumber)Calculates the sample interquartile range.Column number (0 origin).Interquartile range, or missingValueCode if n=0.
double getKurtosis(int columnNumber)Calculates the sample kurtosis.Column number (0 origin).Sample skewness, or missingValueCode if n<4.
double getLowerQuartile(int columnNumber)Calculates the lower quartile of the sample.Column number (0 origin).Lower quartile, or missingValueCode if n=0.
double getMaximum(int columnNumber)Calculates the maximum value in the sample.Column number (0 origin).Sample maximum, or missingValueCode if n=0.
double getMean(int columnNumber)Calculates the sample mean.Column number (0 origin).Sample mean, or missingValueCode if n=0.
double getMedian(int columnNumber)Calculates the sample median.Column number (0 origin).Sample median, or missingValueCode if n=0.
double getMinimum(int columnNumber)Calculates the miniumum value in the sample.Column number (0 origin).Sample minimum, or missingValueCode if n=0.
double getMode(int columnNumber)Calculates the sample mode.Column number (0 origin).Sample mode, or missingValueCode if n=0 or no unique mode exists.
double getRange(int columnNumber)Calculates the sample range.Column number (0 origin).Sample range, or missingValueCode if n=0.
double getSampleSize(int columnNumber)Calculates the number of non-missing data values.Column number (0 origin).Sample size n.
double getSkewness(int columnNumber)Calculates the sample skewness.Column number (0 origin).Sample skewness, or missingValueCode if n<3.
double getStandardDeviation(int columnNumber)Calculates the sample standard deviation.Column number (0 origin).Sample standard deviation, or missingValueCode if n<2.
double getStandardError(int columnNumber)Calculates the standard error of the mean.Column number (0 origin).Sample standard error, or missingValueCode if n<2.
double getStandardizedSkewness(int columnNumber)Calculates the standardized skewness.Column number (0 origin).Standardized skewness, or missingValueCode if n<3.
double getStandardizedKurtosis(int columnNumber)Calculates the standardized kurtosis.Column number (0 origin).Standardized kurtosis, or missingValueCode if n<4.
double getTotal(int columnNumber)Calculates the sum of the data values.Column number (0 origin).Sample sum, or missingValueCode if n=0.
double getUpperQuartile(int columnNumber)Calculates the uppper quartile of the sample.Column number (0 origin).Upper quartile, or missingValueCode if n=0.
double getVariance(int columnNumber)Calculates the sample variance.Column number (0 origin).Sample variance, or missingValueCode if n<2.

Code Sample

//create a ProgramDataSource bean
ProgramDataSource programDataSource1 = new ProgramDataSource();

//create a SampleStatistics bean
SampleStatistics sampleStatistics1 = new SampleStatistics();

//create a data table of 12 rows and 1 column
programDataSource1.createDataTable(12,1,-32768.0);

//assign a name to the first column
programDataSource1.setColumnName(0,"Sales");
programDataSource1.setColumnType(0,'N');

//fill in the data values
for(int i=0; i<12; i++) programDataSource1.setDoubleValue(i,0,(double)(i+1)/12);

//assign the column names for which statistics are desired
java.lang.String[] tempString = new String[1];
tempString[0] = "Sales";
sampleStatistics1.setColumnNames(tempString);

//make the sample statistics bean a listener for changes in the programDataSource bean
programDataSource1.addDataChangeListener(sampleStatistics1.listenerForDataChange);

//notify all listeners
programDataSource1.updateListeners();

//retrieve the results
double mean=sampleStatistics1.getMean(0);
double sigma=sampleStatistics1.getStandardDeviation(0);
double skewness=sampleStatistics1.getStandardizedSkewness(0);
double kurtosis=sampleStatistics1.getStandardizedKurtosis(0);

//display the results
g.drawString("Sample Statistics for Sales",10,20);
g.drawString(" Mean ="+Double.toString(mean),10,40);
g.drawString(" Sigma ="+Double.toString(sigma),10,60);
g.drawString(" Stnd. Skewness ="+Double.toString(skewness),10,80);
g.drawString(" Stnd. Kurtosis ="+Double.toString(kurtosis),10,100);