Calculation STATBEANS®

 

STATBEAN Name: FitDistribution

 

Purpose: Allows Statgraphics to function as distribution fitting software for the retrieval and distribution of data. Fits distributions to a column of data, computes probabilities, and generates random numbers.

Distribution Fitting Software DataSource: None. 

Distribution Fitting Software Read/Write Properties
Name Type Description Possible Values Default Value
origin double Origin of distribution (subtracted from data before fitting distribution). Any double. 0.0
distributionName String[nDists] Name of distribution. From list below. "Normal"
minimumFrequency double Minimum class frequency for chi-squared test. >0 5.0
nDists int Number of distributions entered. 1-25 1
numberOfSuccesses int Number of successes for negative binomial distribution. 1+ 10
populationSize int Size of population for hypergeometric distribution. 1+ 1000
sizeOfSamples int Sample size for binomial and hypergeometric distributions. 1+ 100
xVariableName String[nDists] The name of the column containing data to be fit, if any. Any string. "X"

Other Public Methods For The Distribution Of Data
Name Description Arguments Return Value
double getCdf(double x,int k) Computes cumulative distribution function. Value of random variable x, distribution number. cdf at x.
double getChiSquared(int k) Returns computed chi-squared test statistic. Distribution number. Calculated statistic.
double getChiSquaredDF(int k) Returns degrees of freedom for chi-squared test statistic. Distribution number. Degrees of freedom.
double getChiSquaredPValue(int k) Returns P-value for chi-squared test statistic. Distribution number. P-value.
double getKolmogorovSmirnovD(int k) Returns computed overall KS test statistic. Distribution number. Calculated statistic.
double getKolmogorovSmirnovDMinus(int k) Returns computed lower KS test statistic. Distribution number. Calculated statistic.
double getKolmogorovSmirnovDPlus(int k) Returns computed upper KS test statistic. Distribution number. Calculated statistic.
double getKolmogorovSmirnovPValue(int k) Returns P-value for overall KS test. Distribution number. P-value.
double getShapiroWilksPValue(int k) Returns P-value for Shapiro-Wilks test (for normal distribution only). Distribution number. P-value.
double getShapiroWilksW(int k) Returns computed Shpario-Wilks statictic (for normal distribution only). Distribution number. Calculated statistic.
double getInverseCdf(double p,int k) Computes inverse cumulative distribution function. Value of cdf p, distribution number. Smallest value of x for which cdf is less than or equal to p.
double getMean(int k) Returns the mean of the distribution. Distribution number. Mean.
double getPdf(double x,int k) Computes probability density or mass function. Value of random variable x, distribution number. pdf or pmf at x.
boolean getRandomNumbers(double x[],int n,int k) Generates n random numbers from the distribution, distribution number. Output array,number of random numbers to be generated. true if success
int getSampleSize(int k) Returns the sample size used to fit the distribution. Distribution number. Sample size n, or 0 if no data supplied.
double getVariance(int k) Returns the variance of the distribution. Distribution number. Variance.

 

Available Distributions - see Distributions.

Code Sample 

//create a datasource bean 
FileDataSource fileDataSource1 = new STATBEANS.FileDataSource(); 

//set the file name to be read 
fileDataSource1.setFileName("c:\\statbeans\\samples\\cardata.txt"); 

//create a calculation bean 
FitDistribution fitdistribution1 = new STATBEANS.FitDistribution(); 

//set the column to be fit 
fitdistribution1.setXVariableName("mpg"); 

//set the number and type of distributions to be fit 
fitdistribution1.setNDists(3); 
fitdistribution1.setDistributionName("Normal",0); 
fitdistribution1.setDistributionName("Lognormal",1); 
fitdistribution1.setDistributionName("Weibull",2); 

//create a table bean 
FitDistributionTable fitdistributiontable1 = new STATBEANS.FitDistributionTable(); 

//create a plot bean 
FitDistributionPlot fitdistributionplot1 = new STATBEANS.FitDistributionPlot(); 

//add the beans to the display 
add(fitdistributiontable1); 
add(fitdistributionplot1); 

//make the tabulation bean a listener for changes in the FileDataSource bean 
fileDataSource1.addDataChangeListener(fitdistribution1.listenerForDataChange); 

//make the other beans listeners for changes in the tabulation bean 
fitdistribution1.addDataChangeListener(fitdistributiontable1.listenerForDataChange); 
fitdistribution1.addDataChangeListener(fitdistributionplot1.listenerForDataChange); 

//instruct the fileDataSource bean to read the file 
fileDataSource1.readData();