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 doublemyMeanprotected doublemyMixProb1protected doublemyMixProb2protected ShiftedLossFunctionDistributionSD1protected ShiftedLossFunctionDistributionSD2-
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 doublecdf(double x)Returns the F(x) = Pr{X <= x} where F represents the cumulative distribution functiondoublecomplementaryCDF(double x)Computes the complementary cumulative probability distribution function for given value of xdoublefirstOrderLossFunction(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 parametersRVariableIfcgetRandomVariable(RNStreamIfc rng)doublegetVariance()Returns the variance of the distribution if defineddoubleinvCDF(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 voidmain(java.lang.String[] args)MTPnewInstance()Returns a new instance of the random source with the same parameters but an independent generatordoublesecondOrderLossFunction(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 parametersvoidsetParameters(double rate, double shift, double mixProbability)doublethirdOrderLossFunction(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:
newInstancein interfaceNewInstanceIfc- Specified by:
newInstancein classDistribution- Returns:
- a new instance with the same parameters
-
cdf
public double cdf(double x)
Description copied from interface:CDFIfcReturns the F(x) = Pr{X <= x} where F represents the cumulative distribution function
-
getMean
public double getMean()
Description copied from interface:MeanIfcReturns the mean or expected value of a distribution
-
getParameters
public double[] getParameters()
Description copied from interface:ParametersIfcGets the parameters- Specified by:
getParametersin interfaceParametersIfc- Returns:
- Returns an array of the parameters
-
getVariance
public 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
-
invCDF
public double invCDF(double p)
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:
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:ParametersIfcSets the parameters- Specified by:
setParametersin interfaceParametersIfc- Parameters:
parameters- an array of doubles representing the parameters
-
complementaryCDF
public double complementaryCDF(double x)
Description copied from interface:CDFIfcComputes the complementary cumulative probability distribution function for given value of x- Specified by:
complementaryCDFin 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:FirstOrderLossFunctionIfcComputes the first order loss function for the function for given value of x, G1(x) = E[max(X-x,0)]- Specified by:
firstOrderLossFunctionin 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: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 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:
getRandomVariablein interfaceGetRVariableIfc- Overrides:
getRandomVariablein classDistribution- Parameters:
rng- the stream to use- Returns:
- a random variable
-
main
public static void main(java.lang.String[] args)
-
-