Package jsl.utilities.distributions
Class MTP
- java.lang.Object
-
- jsl.utilities.distributions.Distribution
-
- jsl.utilities.distributions.MTP
-
- All Implemented Interfaces:
ControllableIfc
,CDFIfc
,DistributionFunctionIfc
,DistributionIfc
,FirstOrderLossFunctionIfc
,InverseCDFIfc
,LossFunctionDistributionIfc
,MeanIfc
,SecondOrderLossFunctionIfc
,VarianceIfc
,GetNameIfc
,IdentityIfc
,NewInstanceIfc
,ParametersIfc
,GetRVariableIfc
public class MTP extends Distribution implements LossFunctionDistributionIfc
Represents a Mixed translated Poisson random variable
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jsl.utilities.distributions.Distribution
Distribution.RandomControls
-
-
Field Summary
Fields Modifier and Type Field Description protected double
myMean
protected double
myMixProb1
protected double
myMixProb2
protected ShiftedLossFunctionDistribution
SD1
protected ShiftedLossFunctionDistribution
SD2
-
Fields inherited from class jsl.utilities.distributions.Distribution
myId, myName
-
-
Constructor Summary
Constructors Constructor Description MTP()
defaults mixing prob = 0.5, shift = 0.0, rate = 1.0MTP(double[] parameters)
Constructs an MTP with array of parameters parameters[0] - mixing probability; parameters[1] - shift; parameters[2] - rate;MTP(double mixProb, double shift, double rate)
Constructs an MTP with mixing probabilities 1-mixProb and mixProb with shifts of shift and shift+1 with rates equal to rateMTP(double mixProb, double shift, double rate, java.lang.String name)
Constructs an MTP using the supplied parameters
-
Method Summary
All Methods Static 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
complementaryCDF(double x)
Computes the complementary cumulative probability distribution function for given value of xdouble
firstOrderLossFunction(double x)
Computes the first order loss function for the function for given value of x, G1(x) = E[max(X-x,0)]double
getMean()
Returns the mean or expected value of a distributiondouble[]
getParameters()
Gets the parametersRVariableIfc
getRandomVariable(RNStreamIfc rng)
double
getVariance()
Returns the variance of the distribution if defineddouble
invCDF(double p)
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.static void
main(java.lang.String[] args)
MTP
newInstance()
Returns a new instance of the random source with the same parameters but an independent generatordouble
secondOrderLossFunction(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)]void
setParameters(double[] parameters)
Sets the parametersvoid
setParameters(double rate, double shift, double mixProbability)
double
thirdOrderLossFunction(double x)
-
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.random.rvariable.GetRVariableIfc
getRandomVariable, getRandomVariable
-
Methods inherited from interface jsl.utilities.distributions.VarianceIfc
getStandardDeviation
-
-
-
-
Field Detail
-
myMixProb1
protected double myMixProb1
-
myMixProb2
protected double myMixProb2
-
myMean
protected double myMean
-
SD1
protected ShiftedLossFunctionDistribution SD1
-
SD2
protected ShiftedLossFunctionDistribution SD2
-
-
Constructor Detail
-
MTP
public MTP()
defaults mixing prob = 0.5, shift = 0.0, rate = 1.0
-
MTP
public MTP(double mixProb, double shift, double rate)
Constructs an MTP with mixing probabilities 1-mixProb and mixProb with shifts of shift and shift+1 with rates equal to rate- Parameters:
mixProb
- the mixing probabilityshift
- the shiftrate
- the rate
-
MTP
public MTP(double mixProb, double shift, double rate, java.lang.String name)
Constructs an MTP using the supplied parameters- Parameters:
mixProb
- the mixing probabilityshift
- the shiftrate
- the ratename
- an optional name/label
-
MTP
public MTP(double[] parameters)
Constructs an MTP with array of parameters parameters[0] - mixing probability; parameters[1] - shift; parameters[2] - rate;- Parameters:
parameters
- the parameter array
-
-
Method Detail
-
newInstance
public final MTP newInstance()
Returns a new instance of the random source with the same parameters but an independent generator- Specified by:
newInstance
in interfaceNewInstanceIfc
- Specified by:
newInstance
in classDistribution
- Returns:
- a new instance with the same parameters
-
cdf
public double cdf(double x)
Description copied from interface:CDFIfc
Returns the F(x) = Pr{X <= x} where F represents the cumulative distribution function
-
getMean
public double getMean()
Description copied from interface:MeanIfc
Returns the mean or expected value of a distribution
-
getParameters
public double[] getParameters()
Description copied from interface:ParametersIfc
Gets the parameters- Specified by:
getParameters
in interfaceParametersIfc
- Returns:
- Returns an array of the parameters
-
getVariance
public 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
-
invCDF
public double invCDF(double p)
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:
p
- 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
-
setParameters
public void setParameters(double[] parameters)
Description copied from interface:ParametersIfc
Sets the parameters- Specified by:
setParameters
in interfaceParametersIfc
- Parameters:
parameters
- an array of doubles representing the parameters
-
complementaryCDF
public double complementaryCDF(double x)
Description copied from interface:CDFIfc
Computes the complementary cumulative probability distribution function for given value of x- Specified by:
complementaryCDF
in interfaceCDFIfc
- Parameters:
x
- The value to be evaluated- Returns:
- The probability, 1-P{X<=x}
-
firstOrderLossFunction
public double firstOrderLossFunction(double x)
Description copied from interface:FirstOrderLossFunctionIfc
Computes the first order loss function for the function for given value of x, G1(x) = E[max(X-x,0)]- Specified by:
firstOrderLossFunction
in interfaceFirstOrderLossFunctionIfc
- Parameters:
x
- The value to be evaluated- Returns:
- The loss function value, E[max(X-x,0)]
-
secondOrderLossFunction
public double secondOrderLossFunction(double x)
Description copied from interface:SecondOrderLossFunctionIfc
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)]- Specified by:
secondOrderLossFunction
in interfaceSecondOrderLossFunctionIfc
- Parameters:
x
- The value to be evaluated- Returns:
- The loss function value, (1/2)E[max(X-x,0)*max(X-x-1,0)]
-
thirdOrderLossFunction
public double thirdOrderLossFunction(double x)
-
setParameters
public void setParameters(double rate, double shift, double mixProbability)
- Parameters:
rate
- the rateshift
- the shiftmixProbability
- the mixing 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
-
main
public static void main(java.lang.String[] args)
-
-