jhplot.math.num.pdf
Class Binomial
- java.lang.Object
-
- jhplot.math.num.pdf.DiscreteDistribution
-
- jhplot.math.num.pdf.Binomial
-
- All Implemented Interfaces:
- Distribution
public class Binomial extends DiscreteDistribution
The Binomial distribution.
References:
- Eric W. Weisstein. "Binomial Distribution." From MathWorld--A Wolfram Web Resource. http://mathworld.wolfram.com/Binomial.html
- Since:
- 1.2
-
-
Constructor Summary
Constructors Constructor and Description Binomial()Default constructor.Binomial(int n, double p)Create a distribution with the given number of trials and probability of success.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description doublecumulativeProbability(int x)The CDF for this distribution.intgetNumberOfTrials()Access the number of trials.doublegetProbabilityOfSuccess()Access probability of success.intinverseCumulativeProbability(double p)The inverse CDF for this distribution.doubleprobability(int x)The PMF for this distribution.voidsetNumberOfTrials(int n)Modify the number of trials.voidsetProbabilityOfSuccess(double p)Modify probability of success.
-
-
-
Constructor Detail
-
Binomial
public Binomial()
Default constructor. Number of trials is set to one and probability of success is set to 0.5.
-
Binomial
public Binomial(int n, double p)Create a distribution with the given number of trials and probability of success.- Parameters:
n- the number of trials.p- the probability of success.
-
-
Method Detail
-
cumulativeProbability
public double cumulativeProbability(int x) throws NumericExceptionThe CDF for this distribution. This method returns P(X ≤ x).- Specified by:
cumulativeProbabilityin classDiscreteDistribution- Parameters:
x- the value at which the CDF is evaluated.- Returns:
- CDF for this distribution.
- Throws:
NumericException- if the cumulative probability can not be computed.
-
getNumberOfTrials
public int getNumberOfTrials()
Access the number of trials.- Returns:
- the number of trials.
-
getProbabilityOfSuccess
public double getProbabilityOfSuccess()
Access probability of success.- Returns:
- the probability of success.
-
inverseCumulativeProbability
public int inverseCumulativeProbability(double p) throws NumericExceptionThe inverse CDF for this distribution. This method returns the largest x such that, P(X ≤ x) ≤ p. The return value must also satisfy P(X ≥ x) &ge 1 - p.- Specified by:
inverseCumulativeProbabilityin classDiscreteDistribution- Parameters:
p- the cumulative probability.- Returns:
- x
- Throws:
NumericException- if the inverse cumulative probability can not be computed.
-
probability
public double probability(int x)
The PMF for this distribution. This method returns P(X = x).- Specified by:
probabilityin classDiscreteDistribution- Parameters:
x- the value at which the probability is evaluated.- Returns:
- PMF for this distribution.
-
setNumberOfTrials
public void setNumberOfTrials(int n)
Modify the number of trials.- Parameters:
n- the new number of trials value.
-
setProbabilityOfSuccess
public void setProbabilityOfSuccess(double p)
Modify probability of success.- Parameters:
p- the new probability of success value.
-
-
DMelt 3.0 © DataMelt by jWork.ORG