javanpst.distributions.common.discrete
Class BinomialDistribution
- java.lang.Object
-
- javanpst.distributions.common.discrete.BinomialDistribution
-
- All Implemented Interfaces:
- Distribution
public final class BinomialDistribution extends java.lang.Object implements Distribution
A binomial distribution, with parameters N and P
-
-
Constructor Summary
Constructors Constructor and Description BinomialDistribution()Default builder.BinomialDistribution(BinomialDistribution old)Copy constructor Creates a copy of a given binomial distributionBinomialDistribution(int n, double p)Builder.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description doublecomputeCumulativeProbability(double value)Computes cumulative probability at a given point of the distribution.doublecomputeProbability(double value)Computes mass probability at a given point of the binomial distribution.intgetLesserCumulativeProbability(double limit)Computes the greatest integer whose cumulative probability is lower than a given valueintgetN()Gets the N parameter valuedoublegetP()Gets the P parameter valueintgetUpperCumulativeProbability(double limit)Computes the lowest integer whose cumulative probability is greater than a given valuevoidsetN(int value)Sets the N parameter.voidsetP(double value)Sets the P parameter.java.lang.StringtoString()To String method.
-
-
-
Constructor Detail
-
BinomialDistribution
public BinomialDistribution()
Default builder. Creates a binomial distribution with parameters N=1, P=0.0
-
BinomialDistribution
public BinomialDistribution(int n, double p)Builder. Creates a binomial distribution with parameters N and P- Parameters:
n- N parameterp- P parameter
-
BinomialDistribution
public BinomialDistribution(BinomialDistribution old)
Copy constructor Creates a copy of a given binomial distribution- Parameters:
old- Binomial distribution to copy
-
-
Method Detail
-
setP
public void setP(double value)
Sets the P parameter. Only works if P is in [0.0,1.0]- Parameters:
value- P parameter value
-
getP
public double getP()
Gets the P parameter value- Returns:
- value of P
-
setN
public void setN(int value)
Sets the N parameter. Only works if N is greater than 0- Parameters:
value- N parameter value
-
getN
public int getN()
Gets the N parameter value- Returns:
- value of N
-
computeProbability
public double computeProbability(double value)
Computes mass probability at a given point of the binomial distribution. Value given is converted to integer before computing probability.- Specified by:
computeProbabilityin interfaceDistribution- Parameters:
value- point selected- Returns:
- mass probability at 'value'
-
computeCumulativeProbability
public double computeCumulativeProbability(double value)
Computes cumulative probability at a given point of the distribution. Value given is converted to integer before computing probability.- Specified by:
computeCumulativeProbabilityin interfaceDistribution- Parameters:
value- point selected- Returns:
- cumulative probability at 'value'
-
getLesserCumulativeProbability
public int getLesserCumulativeProbability(double limit)
Computes the greatest integer whose cumulative probability is lower than a given value- Parameters:
limit- Maximum probability allowed- Returns:
- greatest integer found. -1 if there is not any.
-
getUpperCumulativeProbability
public int getUpperCumulativeProbability(double limit)
Computes the lowest integer whose cumulative probability is greater than a given value- Parameters:
limit- Minimum probability allowed- Returns:
- lowest integer found. -1 if there is not any.
-
toString
public java.lang.String toString()
To String method.- Overrides:
toStringin classjava.lang.Object- Returns:
- string representation of the distribution
-
-
DMelt 3.0 © DataMelt by jWork.ORG