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 double
cdf(double x)
Returns the F(x) = Pr{X <= x} where F represents the cumulative distribution functiondouble
getMean()
Returns the mean or expected value of a distributiondouble[]
getParameters()
Gets the parameters as an array parameters[0] is probability of successdouble
getProbabilityOfSuccess()
Gets the probability of successRVariableIfc
getRandomVariable(RNStreamIfc rng)
double
getVariance()
Returns the variance of the distribution if defineddouble
invCDF(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.ShiftedGeometric
newInstance()
Returns a new instancedouble
pmf(double x)
Returns the f(x) where f represents the probability mass function for the distribution.double
pmf(int x)
computes the pmf of the distribution f(x) = p(1-p)^(x-1.0)void
setParameters(double[] parameters)
Sets the parameters using the supplied array parameters[0] is probability of successvoid
setProbabilityOfSuccess(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:NewInstanceIfc
Returns a new instance- Specified by:
newInstance
in interfaceNewInstanceIfc
- Specified by:
newInstance
in 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:MeanIfc
Returns the mean or expected value of a distribution
-
getVariance
public final double getVariance()
Description copied from interface:VarianceIfc
Returns the variance of the distribution if defined- Specified by:
getVariance
in 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:
setParameters
in 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:
getParameters
in 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:PMFIfc
Returns the f(x) where f represents the probability mass function for the distribution.
-
cdf
public final double cdf(double x)
Description copied from interface:CDFIfc
Returns the F(x) = Pr{X <= x} where F represents the cumulative distribution function
-
invCDF
public final double invCDF(double prob)
Description copied from interface:InverseCDFIfc
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.- Specified by:
invCDF
in 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:
getRandomVariable
in interfaceGetRVariableIfc
- Overrides:
getRandomVariable
in classDistribution
- Parameters:
rng
- the stream to use- Returns:
- a random variable
-
-