|
Java Statistical Classes | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Object
|
+--jsc.distributions.AbstractDistribution
|
+--jsc.distributions.AbstractDiscreteDistribution
|
+--jsc.distributions.Binomial
This class represents a binomial distribution.
| Field Summary |
| Fields inherited from class jsc.distributions.AbstractDiscreteDistribution |
maxValue, minValue |
| Fields inherited from class jsc.distributions.AbstractDistribution |
rand |
| Constructor Summary | |
Binomial(long n,
double p)
Create a binomial distribution with parameters n and p. |
|
| Method Summary | |
double |
cdf(double x)
Returns the value of the cumulative density function at a variate-value x. |
long |
getN()
|
double |
getP()
|
double |
inverseCdf(double prob)
Returns the inverse of binomial distribution. |
double |
mean()
Returns true indicating that the distribution is discrete. |
double |
pdf(double x)
Returns the value of the probability mass function at variate-value x. |
double |
random()
Returns as a double number an integer value that is a random variate-value drawn from the binomial distribution. |
void |
setN(long n)
Change the "number of trials" parameter. |
void |
setP(double p)
Change the "probability of success" parameter. |
String |
toString()
|
double |
variance()
Return variance of the distribution. |
| Methods inherited from class jsc.distributions.AbstractDiscreteDistribution |
getMaximumPdf, getMaxValue, getMinValue, isDiscrete, moment, moment |
| Methods inherited from class jsc.distributions.AbstractDistribution |
sd, setSeed |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public Binomial(long n,
double p)
n - the "number of trials" parameter; must be greater than 0.p - the "probability of success" parameter; must be greater
than 0 and less than 1.
IllegalArgumentException - if n less than 1.
IllegalArgumentException - if p not in (0,1).| Method Detail |
public double cdf(double x)
cdf in interface Distributioncdf in class AbstractDiscreteDistributionx - a variate-value; must be in [0,n].
IllegalArgumentException - if x less than 0 or greater than n.public long getN()
public double getP()
public double inverseCdf(double prob)
inverseCdf in interface DistributioninverseCdf in class AbstractDiscreteDistributionprob - the value of the probability; must be in [0,1].
IllegalArgumentException - if prob is less than 0 or greater than 1.public double mean()
mean in interface Distributionmean in class AbstractDiscreteDistributionpublic double pdf(double x)
pdf in interface Distributionpdf in class AbstractDiscreteDistributionx - a variate-value.
public double random()
random in interface Distributionrandom in class AbstractDistributionpublic void setN(long n)
n - the "number of trials" parameter; must be greater than 0.
IllegalArgumentException - if n less than 1.public void setP(double p)
p - the "probability of success" parameter; must be greater
than 0 and less than 1.
IllegalArgumentException - if p not in (0,1).public String toString()
toString in class Objectpublic double variance()
AbstractDiscreteDistributionmean(); so if the mean is already calculated, it is more
efficient to call moment(2,mean) than use this method.
The variance is usually known in terms of the distribution's parameters,
so this method should be overridden.
variance in interface Distributionvariance in class AbstractDiscreteDistribution
|
Java Statistical Classes | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||