Package jsl.utilities.distributions
Class Geometric
- java.lang.Object
- 
- jsl.utilities.distributions.Distribution
- 
- jsl.utilities.distributions.Geometric
 
 
- 
- All Implemented Interfaces:
- ControllableIfc,- CDFIfc,- DiscreteDistributionIfc,- DistributionFunctionIfc,- DistributionIfc,- FirstOrderLossFunctionIfc,- InverseCDFIfc,- LossFunctionDistributionIfc,- MeanIfc,- PMFIfc,- SecondOrderLossFunctionIfc,- VarianceIfc,- GetNameIfc,- IdentityIfc,- NewInstanceIfc,- ParametersIfc,- GetRVariableIfc
 
 public class Geometric extends Distribution implements DiscreteDistributionIfc, LossFunctionDistributionIfc, GetRVariableIfc The geometric distribution is the probability distribution of the number Y = X − 1 of failures before the first success, supported on the set { 0, 1, 2, 3, ... }, where X is the number of Bernoulli trials needed to get one success.
- 
- 
Nested Class Summary- 
Nested classes/interfaces inherited from class jsl.utilities.distributions.DistributionDistribution.RandomControls
 
- 
 - 
Field Summary- 
Fields inherited from class jsl.utilities.distributions.DistributionmyId, myName
 
- 
 - 
Constructor SummaryConstructors Constructor Description Geometric()Constructs a Geometric with success probability = 0.5Geometric(double prob)Constructs a Geometric using the supplied success probabilityGeometric(double[] parameters)Constructs a Geometric using the supplied parameters array parameters[0] is probability of successGeometric(double prob, java.lang.String name)Constructs a Geometric using the supplied success probability and lower range
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleancanMatchMoments(double... moments)doublecdf(double x)computes the cdf of the distribution F(X<=x)static GeometriccreateFromMoments(double... moments)doublefirstOrderLossFunction(double x)Computes the first order loss function for the function for given value of x, G1(x) = E[max(X-x,0)]doublegetMean()Returns the mean or expected value of a distributiondouble[]getParameters()Gets the parameters as an array parameters[0] is probability of successstatic double[]getParametersFromMoments(double... moments)doublegetProbabilityOfSuccess()Gets the probability of successRVariableIfcgetRandomVariable(RNStreamIfc rng)doublegetVariance()Returns the variance of the distribution if defineddoubleinvCDF(double prob)Gets the inverse cdf for the distributionGeometricnewInstance()Returns a new instancedoublepmf(double x)If x is not and integer value, then the probability must be zero otherwise pmf(int x) is used to determine the probabilitydoublepmf(int x)computes the pmf of the distribution f(x) = p(1-p)^(x) for x>=0, 0 otherwisedoublesecondOrderLossFunction(double x)Computes the 2nd order loss function for the distribution function for given value of x, G2(x) = (1/2)E[max(X-x,0)*max(X-x-1,0)]voidsetParameters(double[] parameters)Sets the parameters using the supplied array parameters[0] is probability of success parameters[1] is lower rangevoidsetProbabilityOfSuccess(double prob)Sets the probability of success- 
Methods inherited from class jsl.utilities.distributions.DistributiongetControls, getId, getName, getStandardDeviation, inverseContinuousCDFViaBisection, inverseContinuousCDFViaBisection, inverseDiscreteCDFViaSearchUp, setControls, setId, setName, toString
 - 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 - 
Methods inherited from interface jsl.utilities.distributions.CDFIfccdf, complementaryCDF
 - 
Methods inherited from interface jsl.utilities.random.rvariable.GetRVariableIfcgetRandomVariable, getRandomVariable
 - 
Methods inherited from interface jsl.utilities.distributions.VarianceIfcgetStandardDeviation
 
- 
 
- 
- 
- 
Constructor Detail- 
Geometricpublic Geometric() Constructs a Geometric with success probability = 0.5
 - 
Geometricpublic Geometric(double[] parameters) Constructs a Geometric using the supplied parameters array parameters[0] is probability of success- Parameters:
- parameters- the parameter array
 
 - 
Geometricpublic Geometric(double prob) Constructs a Geometric using the supplied success probability- Parameters:
- prob- , the probability of success
 
 - 
Geometricpublic Geometric(double prob, java.lang.String name)Constructs a Geometric using the supplied success probability and lower range- Parameters:
- prob- the probability of success
- name- an optional label/name
 
 
- 
 - 
Method Detail- 
newInstancepublic final Geometric newInstance() Description copied from interface:NewInstanceIfcReturns a new instance- Specified by:
- newInstancein interface- NewInstanceIfc
- Specified by:
- newInstancein class- Distribution
- Returns:
- the new instance
 
 - 
setProbabilityOfSuccesspublic final void setProbabilityOfSuccess(double prob) Sets the probability of success- Parameters:
- prob- the probability of success
 
 - 
getProbabilityOfSuccesspublic final double getProbabilityOfSuccess() Gets the probability of success- Returns:
- the probability of success
 
 - 
getMeanpublic final double getMean() Description copied from interface:MeanIfcReturns the mean or expected value of a distribution
 - 
getVariancepublic final double getVariance() Description copied from interface:VarianceIfcReturns the variance of the distribution if defined- Specified by:
- getVariancein interface- VarianceIfc
- Returns:
- double the variance of the random variable
 
 - 
setParameterspublic final void setParameters(double[] parameters) Sets the parameters using the supplied array parameters[0] is probability of success parameters[1] is lower range- Specified by:
- setParametersin interface- ParametersIfc
- Parameters:
- parameters- the parameter array
 
 - 
getParameterspublic final double[] getParameters() Gets the parameters as an array parameters[0] is probability of success- Specified by:
- getParametersin interface- ParametersIfc
- Returns:
- Returns an array of the parameters
 
 - 
pmfpublic final double pmf(int x) computes the pmf of the distribution f(x) = p(1-p)^(x) for x>=0, 0 otherwise- Parameters:
- x- the value to evaluate
- Returns:
- the probability
 
 - 
pmfpublic final double pmf(double x) If x is not and integer value, then the probability must be zero otherwise pmf(int x) is used to determine the probability
 - 
cdfpublic final double cdf(double x) computes the cdf of the distribution F(X<=x)
 - 
invCDFpublic final double invCDF(double prob) Gets the inverse cdf for the distribution- Specified by:
- invCDFin interface- InverseCDFIfc
- Parameters:
- prob- Must be in range [0,1)
- Returns:
- The inverse cdf evaluated at the supplied probability
 
 - 
canMatchMomentspublic static boolean canMatchMoments(double... moments) 
 - 
getParametersFromMomentspublic static double[] getParametersFromMoments(double... moments) 
 - 
createFromMomentspublic static Geometric createFromMoments(double... moments) 
 - 
firstOrderLossFunctionpublic double firstOrderLossFunction(double x) Description copied from interface:FirstOrderLossFunctionIfcComputes the first order loss function for the function for given value of x, G1(x) = E[max(X-x,0)]- Specified by:
- firstOrderLossFunctionin interface- FirstOrderLossFunctionIfc
- Parameters:
- x- The value to be evaluated
- Returns:
- The loss function value, E[max(X-x,0)]
 
 - 
secondOrderLossFunctionpublic double secondOrderLossFunction(double x) Description copied from interface:SecondOrderLossFunctionIfcComputes the 2nd order loss function for the distribution function for given value of x, G2(x) = (1/2)E[max(X-x,0)*max(X-x-1,0)]- Specified by:
- secondOrderLossFunctionin interface- SecondOrderLossFunctionIfc
- Parameters:
- x- The value to be evaluated
- Returns:
- The loss function value, (1/2)E[max(X-x,0)*max(X-x-1,0)]
 
 - 
getRandomVariablepublic final RVariableIfc getRandomVariable(RNStreamIfc rng) - Specified by:
- getRandomVariablein interface- GetRVariableIfc
- Overrides:
- getRandomVariablein class- Distribution
- Parameters:
- rng- the stream to use
- Returns:
- a random variable
 
 
- 
 
-