Calculation STATBEANS®

 

STATBEAN Name: Distributions

 

Purpose: calculating probability and generating random numbers for many probability distributions. This STATBEAN uses JavaBeans to give Statgraphics a probability distribution calculator.

DataSource for the STATBEAN probability distribution calculator: None.

Calculating Probability Read/Write Properties

Name Type Description Possible Values Default Value
distributionName String[nDists] Name of distribution. From list below. "Normal"
nDists int Number of distributions entered. 1-25 1
parameter1 double[nDists] First parameters for the distribution. Valid parameter. 0.0
parameter2 double[nDists] Second parameters for the distribution. Valid parameter. 1.0
parameter3 double[nDists] Third parameters for the distribution. Valid parameter. 0.0

Other Public Methods For Calculating Probability With Statgraphics
Name Description Arguments Return Value
void calculateStatistics() Causes the function to calculate the desired distributions. None. None.
double getCdf(double x,int k) Computes cumulative distribution function. Value of random variable x, distribution number. cdf at x.
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
double getVariance(int k) Returns the variance of the distribution. Distribution number. Variance.

Available Discrete Distributions
Name Range of X Parameters Restrictions Mean
Bernoulli 0,1 probability p 0<=p<=1 p
Binomial 0,1,...,n probability p,
sample size n
n>=1,
0<=p<=1
np
Discrete Uniform a,a+1,...,b lower limit a,
upper limit b
a<=b (a+b)/2
Geometric 0,1,2,... probability p 1>=p>0 (1-p)/p
Hypergeometric 0,1,...,min(m,n) number of successes m,
sample size n,
population size N
N>=m>=0,
N>=n>=1
mn/N
Negative Binomial k,k+1,... probability p,
number of successes k
1>=p>0,
k>0
k/p
Poisson 0,1,2,... mean lambda lambda>0 lambda

Available Continuous Distributions For The Probability Distribution Calculator
Name Range of X Parameters Restrictions Mean
Beta 0<=X<=1 shape alpha1,
shape alpha2
alpha1>0,
alpha2>0
alpha1/(alpha1+alpha2)
Cauchy all real X median theta,
shape beta
beta>0 not defined
Chi-Square X>=0 degrees of freedom v v>0 v
Erlang X>=0 shape alpha,
scale lambda
integer alpha>=1,
lambda>0
alpha/lambda
Exponential X>=0 scale lambda lambda>0 1/lambda
Extreme Value all real X shape alpha,
scale beta
beta>0 alpha-0.57721*beta
F X>=0 num. d.f. v,
den. d.f. w
integer v>=1,
integer w>=1
w/(w-2)
Gamma X>=0 shape alpha,
scale lambda
alpha>0,
lambda>0
alpha/lambda
Laplace all real X mean mu,
scale lambda
lambda>0 mu
(note: sigma=sqrt(2)/lambda)
Logistic all real X mean mu,
std. dev. sigma
sigma>0 mu
Lognormal X>0 mean mu,
std. dev. sigma
sigma>0 exp(mu+sigma*sigma/2)
Normal all real X mean mu,
std. dev. sigma
sigma>0 mu
Pareto X>=1 scale c c>0 c/(c-1)
Student's t all real X degrees of freedom v v>=1 0
Triangular a<=X<=b minimum a,
mode c,
maximum b
a<=c<=b (a+b+c)/3
Uniform a<=X<=b minimum a,
maximum b
a<=b (a+b)/2
Weibull X>=0 shape alpha,
scale beta
alpha>0,
beta>0
(beta*gamma(1/alpha))/alpha


Calculating Probability Code Sample

//create a calculation bean 
Distributions distributions1 = new STATBEANS.Distributions(); 

//set the number of distributions to be evaluated 
distributions1.setNDists(2); 

//define each distribution 
distributions1.setDistributionName("Normal",0); 
distributions1.setParameter1(50.0,0); 
distributions1.setParameter2(10.0,0); 
distributions1.setDistributionName("Lognormal",1); 
distributions1.setParameter1(50.0,1); 
distributions1.setParameter2(20.0,1); 

//set up a table to display probabilities 
DistributionsTable distributionsTable1 = new STATBEANS.DistributionsTable(); 

//define values for which probabilities are desired 
double x[]=new double[6]; 
x[0]=10.0; 
x[1]=20.0; 
x[2]=30.0; 
x[3]=40.0; 
x[4]=50.0; 
x[5]=60.0; 
distributionsTable1.setValues(x); 

//add the table to the display 
add(distributionsTable1); 

//create a plot bean 
DistributionsPlot distributionsPlot1 = new STATBEANS.DistributionsPlot(); 

//add the plot to the display 
add(distributionsPlot1); 

//make the table and plot beans listeners for changes in the calculation bean 
distributions1.addDataChangeListener(distributionsTable1.listenerForDataChange); 
distributions1.addDataChangeListener(distributionsPlot1.listenerForDataChange); 

//instruct the calculation bean to compute the probabilities 
distributions1.calculateStatistics();