Package jsl.utilities.distributions
Class ShiftedGeometric
- java.lang.Object
-
- jsl.utilities.distributions.Distribution
-
- jsl.utilities.distributions.ShiftedGeometric
-
- All Implemented Interfaces:
ControllableIfc,CDFIfc,DiscreteDistributionIfc,DistributionFunctionIfc,DistributionIfc,InverseCDFIfc,MeanIfc,PMFIfc,VarianceIfc,GetNameIfc,IdentityIfc,NewInstanceIfc,ParametersIfc,GetRVariableIfc
public class ShiftedGeometric extends Distribution implements DiscreteDistributionIfc, GetRVariableIfc
The ShiftedeGeometric distribution is the probability distribution of the number of Bernoulli trials needed to get one success. supported on the set {1, 2, 3, ... }
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jsl.utilities.distributions.Distribution
Distribution.RandomControls
-
-
Field Summary
-
Fields inherited from class jsl.utilities.distributions.Distribution
myId, myName
-
-
Constructor Summary
Constructors Constructor Description ShiftedGeometric()Constructs a ShiftedGeometric with success probability = 0.5ShiftedGeometric(double prob)Constructs a ShiftedGeometric using the supplied success probabilityShiftedGeometric(double[] parameters)Constructs a ShiftedGeometric using the supplied parameters array parameters[0] is probability of successShiftedGeometric(double prob, java.lang.String name)Constructs a ShiftedGeometric using the supplied success probability
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description doublecdf(double x)Returns the F(x) = Pr{X <= x} where F represents the cumulative distribution functiondoublegetMean()Returns the mean or expected value of a distributiondouble[]getParameters()Gets the parameters as an array parameters[0] is probability of successdoublegetProbabilityOfSuccess()Gets the probability of successRVariableIfcgetRandomVariable(RNStreamIfc rng)doublegetVariance()Returns the variance of the distribution if defineddoubleinvCDF(double prob)Provides the inverse cumulative distribution function for the distribution While closed form solutions for the inverse cdf may not exist, numerical search methods can be used to solve F(X) = U.ShiftedGeometricnewInstance()Returns a new instancedoublepmf(double x)Returns the f(x) where f represents the probability mass function for the distribution.doublepmf(int x)computes the pmf of the distribution f(x) = p(1-p)^(x-1.0)voidsetParameters(double[] parameters)Sets the parameters using the supplied array parameters[0] is probability of successvoidsetProbabilityOfSuccess(double prob)Sets the probability of success-
Methods inherited from class jsl.utilities.distributions.Distribution
getControls, getId, getName, getStandardDeviation, inverseContinuousCDFViaBisection, inverseContinuousCDFViaBisection, inverseDiscreteCDFViaSearchUp, setControls, setId, setName, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface jsl.utilities.distributions.CDFIfc
cdf, complementaryCDF
-
Methods inherited from interface jsl.utilities.random.rvariable.GetRVariableIfc
getRandomVariable, getRandomVariable
-
-
-
-
Constructor Detail
-
ShiftedGeometric
public ShiftedGeometric()
Constructs a ShiftedGeometric with success probability = 0.5
-
ShiftedGeometric
public ShiftedGeometric(double[] parameters)
Constructs a ShiftedGeometric using the supplied parameters array parameters[0] is probability of success- Parameters:
parameters-
-
ShiftedGeometric
public ShiftedGeometric(double prob)
Constructs a ShiftedGeometric using the supplied success probability- Parameters:
prob- the probability of success
-
ShiftedGeometric
public ShiftedGeometric(double prob, java.lang.String name)Constructs a ShiftedGeometric using the supplied success probability- Parameters:
prob- the probability of successname- an optional name/label
-
-
Method Detail
-
newInstance
public final ShiftedGeometric newInstance()
Description copied from interface:NewInstanceIfcReturns a new instance- Specified by:
newInstancein interfaceNewInstanceIfc- Specified by:
newInstancein classDistribution- Returns:
- the new instance
-
setProbabilityOfSuccess
public final void setProbabilityOfSuccess(double prob)
Sets the probability of success- Parameters:
prob- the probability of success
-
getProbabilityOfSuccess
public final double getProbabilityOfSuccess()
Gets the probability of success- Returns:
- the probability of success
-
getMean
public final double getMean()
Description copied from interface:MeanIfcReturns the mean or expected value of a distribution
-
getVariance
public final double getVariance()
Description copied from interface:VarianceIfcReturns the variance of the distribution if defined- Specified by:
getVariancein interfaceVarianceIfc- Returns:
- double the variance of the random variable
-
setParameters
public final void setParameters(double[] parameters)
Sets the parameters using the supplied array parameters[0] is probability of success- Specified by:
setParametersin interfaceParametersIfc- Parameters:
parameters- the parameter array
-
getParameters
public final double[] getParameters()
Gets the parameters as an array parameters[0] is probability of success- Specified by:
getParametersin interfaceParametersIfc- Returns:
- the parameter array
-
pmf
public final double pmf(int x)
computes the pmf of the distribution f(x) = p(1-p)^(x-1.0)- Parameters:
x- the value to evaluate- Returns:
- the probability at x
-
pmf
public final double pmf(double x)
Description copied from interface:PMFIfcReturns the f(x) where f represents the probability mass function for the distribution.
-
cdf
public final double cdf(double x)
Description copied from interface:CDFIfcReturns the F(x) = Pr{X <= x} where F represents the cumulative distribution function
-
invCDF
public final double invCDF(double prob)
Description copied from interface:InverseCDFIfcProvides the inverse cumulative distribution function for the distribution While closed form solutions for the inverse cdf may not exist, numerical search methods can be used to solve F(X) = U.- Specified by:
invCDFin interfaceInverseCDFIfc- Parameters:
prob- The probability to be evaluated for the inverse, p must be [0,1] or an IllegalArgumentException is thrown- Returns:
- The inverse cdf evaluated at the supplied probability
-
getRandomVariable
public final RVariableIfc getRandomVariable(RNStreamIfc rng)
- Specified by:
getRandomVariablein interfaceGetRVariableIfc- Overrides:
getRandomVariablein classDistribution- Parameters:
rng- the stream to use- Returns:
- a random variable
-
-