## edu.ucla.stat.SOCR.distributions Class BinomialDistribution

```java.lang.Object
edu.ucla.stat.SOCR.core.SOCRValueSettable
edu.ucla.stat.SOCR.core.Distribution
edu.ucla.stat.SOCR.distributions.BinomialDistribution
```
All Implemented Interfaces:
IValueSettable, Pluginable, java.util.Observer
Direct Known Subclasses:
BernoulliDistribution

`public class BinomialDistributionextends Distribution`

The binomial distribution with specified parameters: the number of trials (n) and the probability of success (p) http://mathworld.wolfram.com/BinomialDistribution.html .

Field Summary

Fields inherited from class edu.ucla.stat.SOCR.core.Distribution
`applet, CONTINUOUS, DISCRETE, MAXMGFXVAL, MAXMGFYVAL, MINMGFXVAL, MIXED, name`

Constructor Summary
`BinomialDistribution()`
Default constructor: creates the binomial distribution with 10 trials and probability of success 1/2
`BinomialDistribution(double[] distData)`

`BinomialDistribution(float[] distData)`

```BinomialDistribution(int n, double p)```
General constructor: creates the binomial distribution with specified parameters

Method Summary
` double` `getCDF(double x)`
Specify the CDF in terms of the beta CDF
` double` `getDensity(double x)`
Define the binomial getDensity function
` double` `getMaxDensity()`
Specify the maximum getDensity
` double` `getMean()`
Give the mean in closed form
` double` `getMGF(double t)`
Computes the moment generating function in closed form for a parameter t which lies in the domain of the distribution.
` double` `getMode()`
Give the Mode in closed form
` java.lang.String` `getOnlineDescription()`
This method returns an online description of this distribution.
` double` `getPGF(double t)`
Computes the probability generating function in closed form for a parameter t which lies in the domain of the distribution.
` double` `getProbability()`
Get the probability of success
` double` `getSD()`
Specify the SD in close form
` int` `getTrials()`
Get the number of trials
` double` `getVariance()`
Specify the variance in close form
` void` `initialize()`
used for some subclass to initialize before being used
` double` `inverseCDF(double probability)`
Inverse of the cumulative Poisson distribution function.
` void` `paramEstimate(double[] distData)`
overwrites the method in Distribution for estimating parameters
` void` ```setParameters(int n, double p)```
Set the parameters
` void` `setProbability(double p)`
Set the probability of success
` void` `setTrials(int n)`
Set the number of trails
` double` `simulate()`
Simulate the binomial distribution as the number of successes in n trials
` void` `valueChanged()`

Methods inherited from class edu.ucla.stat.SOCR.core.Distribution
`addObserver, betaCDF, comb, factorial, findGFRoot, findRoot, gamma, gammaCDF, getDisplayPane, getDomain, getFailureRate, getGFDerivative, getGFSecondDerivative, getInstance, getLocalHelp, getMean, getMedian, getMgfDomain, getName, getPGFDomain, getQuantile, getSampleMoment, getSOCRDistributionFunctors, getSOCRDistributions, getType, getVariance, logGamma, perm, sampleMean, sampleVar, setApplet, setDomain, setDomain, setMGFDomain, setMGFDomain, setMGFParameters, setMGFParameters, setMGFParameters, setMGFParameters, setParameters, setPGFDomain, setPGFDomain, setPGFParameters, setPGFParameters, setPGFParameters, setPGFParameters, update, valueChanged`

Methods inherited from class edu.ucla.stat.SOCR.core.SOCRValueSettable
`createComponentSetter, createValueSetter, createValueSetter, createValueSetter, createValueSetter, getComponentSetter, getComponentSetters, getValueSetter, getValueSetters`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### BinomialDistribution

`public BinomialDistribution()`
Default constructor: creates the binomial distribution with 10 trials and probability of success 1/2

### BinomialDistribution

```public BinomialDistribution(int n,
double p)```
General constructor: creates the binomial distribution with specified parameters

### BinomialDistribution

`public BinomialDistribution(double[] distData)`

### BinomialDistribution

`public BinomialDistribution(float[] distData)`
Method Detail

### initialize

`public void initialize()`
Description copied from class: `Distribution`
used for some subclass to initialize before being used

Overrides:
`initialize` in class `Distribution`

### valueChanged

`public void valueChanged()`
Overrides:
`valueChanged` in class `Distribution`

### setParameters

```public void setParameters(int n,
double p)```
Set the parameters

### setTrials

`public void setTrials(int n)`
Set the number of trails

### getTrials

`public int getTrials()`
Get the number of trials

### setProbability

`public void setProbability(double p)`
Set the probability of success

### getProbability

`public double getProbability()`
Get the probability of success

### getDensity

`public double getDensity(double x)`
Define the binomial getDensity function

Specified by:
`getDensity` in class `Distribution`

### getMaxDensity

`public double getMaxDensity()`
Specify the maximum getDensity

Overrides:
`getMaxDensity` in class `Distribution`

### getMean

`public double getMean()`
Give the mean in closed form

Overrides:
`getMean` in class `Distribution`

### getMode

`public double getMode()`
Give the Mode in closed form

### getVariance

`public double getVariance()`
Specify the variance in close form

Overrides:
`getVariance` in class `Distribution`

### getSD

`public double getSD()`
Specify the SD in close form

Overrides:
`getSD` in class `Distribution`

### getMGF

`public double getMGF(double t)`
Computes the moment generating function in closed form for a parameter t which lies in the domain of the distribution.

Overrides:
`getMGF` in class `Distribution`

### getPGF

`public double getPGF(double t)`
Computes the probability generating function in closed form for a parameter t which lies in the domain of the distribution.

Overrides:
`getPGF` in class `Distribution`

### getCDF

`public double getCDF(double x)`
Specify the CDF in terms of the beta CDF

Overrides:
`getCDF` in class `Distribution`

### inverseCDF

`public double inverseCDF(double probability)`
Inverse of the cumulative Poisson distribution function.

Overrides:
`inverseCDF` in class `Distribution`
Parameters:
`probability` - - a probability value in [0, 1]
Returns:
the value X for which P(x<X).

### simulate

`public double simulate()`
Simulate the binomial distribution as the number of successes in n trials

Overrides:
`simulate` in class `Distribution`

### paramEstimate

`public void paramEstimate(double[] distData)`
overwrites the method in Distribution for estimating parameters

Overrides:
`paramEstimate` in class `Distribution`
Parameters:
`distData` - array of raw data

### getOnlineDescription

`public java.lang.String getOnlineDescription()`
This method returns an online description of this distribution.

Overrides:
`getOnlineDescription` in class `Distribution`