Package jsl.utilities.distributions
Class ShiftedDistribution
- java.lang.Object
-
- jsl.utilities.distributions.Distribution
-
- jsl.utilities.distributions.ShiftedDistribution
-
- All Implemented Interfaces:
ControllableIfc
,CDFIfc
,DistributionFunctionIfc
,DistributionIfc
,FirstOrderLossFunctionIfc
,InverseCDFIfc
,LossFunctionDistributionIfc
,MeanIfc
,SecondOrderLossFunctionIfc
,VarianceIfc
,GetNameIfc
,IdentityIfc
,NewInstanceIfc
,ParametersIfc
,GetRVariableIfc
- Direct Known Subclasses:
ShiftedLossFunctionDistribution
public class ShiftedDistribution extends Distribution implements LossFunctionDistributionIfc
Represents a Distribution that has been Shifted (translated to the right) The shift must be >= 0.0
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jsl.utilities.distributions.Distribution
Distribution.RandomControls
-
-
Field Summary
Fields Modifier and Type Field Description protected DistributionIfc
myDistribution
protected LossFunctionDistributionIfc
myLossFunctionDistribution
protected double
myShift
-
Fields inherited from class jsl.utilities.distributions.Distribution
myId, myName
-
-
Constructor Summary
Constructors Constructor Description ShiftedDistribution(DistributionIfc distribution, double shift)
Constructs a shifted distribution based on the provided distributionShiftedDistribution(DistributionIfc distribution, double shift, java.lang.String name)
Constructs a shifted distribution based on t he provided distribution
-
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
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 parameters for the shifted distribution shift = parameter[0] The other elements of the returned array are the parameters of the underlying distributionRVariableIfc
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.ShiftedDistribution
newInstance()
Returns a new instancedouble
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
setDistribution(DistributionIfc distribution, double shift)
Changes the underlying distribution and the shiftvoid
setParameters(double[] parameters)
Sets the parameters of the shifted distribution shift = parameter[0] If supplied, the other elements of the array are used in setting the parameters of the underlying distribution.void
setShift(double shift)
Changes the shiftdouble
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.distributions.CDFIfc
cdf, complementaryCDF
-
Methods inherited from interface jsl.utilities.random.rvariable.GetRVariableIfc
getRandomVariable, getRandomVariable
-
Methods inherited from interface jsl.utilities.distributions.VarianceIfc
getStandardDeviation
-
-
-
-
Field Detail
-
myDistribution
protected DistributionIfc myDistribution
-
myLossFunctionDistribution
protected LossFunctionDistributionIfc myLossFunctionDistribution
-
myShift
protected double myShift
-
-
Constructor Detail
-
ShiftedDistribution
public ShiftedDistribution(DistributionIfc distribution, double shift)
Constructs a shifted distribution based on the provided distribution- Parameters:
distribution
- the distribution to shiftshift
- The linear shift
-
ShiftedDistribution
public ShiftedDistribution(DistributionIfc distribution, double shift, java.lang.String name)
Constructs a shifted distribution based on t he provided distribution- Parameters:
distribution
- the distribution to shiftshift
- The linear shiftname
- an optional name/label
-
-
Method Detail
-
newInstance
public final ShiftedDistribution newInstance()
Description copied from interface:NewInstanceIfc
Returns a new instance- Specified by:
newInstance
in interfaceNewInstanceIfc
- Specified by:
newInstance
in classDistribution
- Returns:
- the new instance
-
setDistribution
public final void setDistribution(DistributionIfc distribution, double shift)
Changes the underlying distribution and the shift- Parameters:
distribution
- must not be nullshift
- must be >=0.0
-
setShift
public final void setShift(double shift)
Changes the shift- Parameters:
shift
- must be >=0.0
-
setParameters
public final void setParameters(double[] parameters)
Sets the parameters of the shifted distribution shift = parameter[0] If supplied, the other elements of the array are used in setting the parameters of the underlying distribution. If only the shift is supplied as a parameter, then the underlying distribution's parameters are not changed (and do not need to be supplied)- Specified by:
setParameters
in interfaceParametersIfc
- Parameters:
parameters
- an array of doubles representing the parameters
-
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
-
getMean
public final double getMean()
Description copied from interface:MeanIfc
Returns the mean or expected value of a distribution
-
getParameters
public final double[] getParameters()
Gets the parameters for the shifted distribution shift = parameter[0] The other elements of the returned array are the parameters of the underlying distribution- 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
-
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)
-
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
-
-