Package jsl.utilities.distributions
Class Lognormal
- java.lang.Object
-
- jsl.utilities.distributions.Distribution
-
- jsl.utilities.distributions.Lognormal
-
- All Implemented Interfaces:
ControllableIfc,CDFIfc,ContinuousDistributionIfc,DistributionFunctionIfc,DistributionIfc,DomainIfc,FirstOrderLossFunctionIfc,InverseCDFIfc,LossFunctionDistributionIfc,MeanIfc,PDFIfc,SecondOrderLossFunctionIfc,VarianceIfc,GetNameIfc,IdentityIfc,NewInstanceIfc,ParametersIfc,GetRVariableIfc
public class Lognormal extends Distribution implements ContinuousDistributionIfc, LossFunctionDistributionIfc, InverseCDFIfc, GetRVariableIfc
Models the lognormal distribution This distribution is commonly use to model the time of a task
-
-
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 Lognormal()Constructs a lognormal distribution with mean 1.0 and variance 1.0Lognormal(double[] parameters)Constructs a lognormal distribution with mean = parameters[0] and variance = parameters[1]Lognormal(double mean, double variance)Constructs a lognormal distribution with mean and variance.Lognormal(double mean, double variance, java.lang.String name)Constructs a lognormal distribution with mean and variance.
-
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 functiondoublefirstOrderLossFunction(double x)Computes the first order loss function for the function for given value of x, G1(x) = E[max(X-x,0)]IntervalgetDomain()doublegetKurtosis()Gets the kurtosis of the distributiondoublegetMean()Returns the mean or expected value of a distributiondoublegetMoment3()doublegetMoment4()NormalgetNormal()Provides a normal distribution with correct parameters as related to this lognormal distributiondoublegetNormalMean()The mean of the underlying normaldoublegetNormalStdDev()The standard deviation of the underlying normaldoublegetNormalVariance()The variance of the underlying normaldouble[]getParameters()Gets the parameters for the distributionRVariableIfcgetRandomVariable(RNStreamIfc rng)doublegetSkewness()Gets the skewness of the distributiondoublegetVariance()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.LognormalnewInstance()Returns a new instancedoublepdf(double x)Returns the f(x) where f represents the probability density function for the distribution.doublesecondOrderLossFunction(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 parameters for the distribution mean = parameters[0] and variance = parameters[1]voidsetParameters(double mean, double variance)Sets the parameters of a lognormal distribution to mean and variance.-
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
-
-
-
-
Constructor Detail
-
Lognormal
public Lognormal()
Constructs a lognormal distribution with mean 1.0 and variance 1.0
-
Lognormal
public Lognormal(double[] parameters)
Constructs a lognormal distribution with mean = parameters[0] and variance = parameters[1]- Parameters:
parameters- An array with the mean and variance
-
Lognormal
public Lognormal(double mean, double variance)Constructs a lognormal distribution with mean and variance. Note: these parameters are the actual mean and variance of the lognormal, not the underlying normal as in many other implementations.- Parameters:
mean- must be > 0variance- must be > 0
-
Lognormal
public Lognormal(double mean, double variance, java.lang.String name)Constructs a lognormal distribution with mean and variance. Note: these parameters are the actual mean and variance of the lognormal, not the underlying normal as in many other implementations.- Parameters:
mean- must be > 0variance- must be > 0name- an optional name/lable
-
-
Method Detail
-
newInstance
public final Lognormal newInstance()
Description copied from interface:NewInstanceIfcReturns a new instance- Specified by:
newInstancein interfaceNewInstanceIfc- Specified by:
newInstancein classDistribution- Returns:
- the new instance
-
setParameters
public final void setParameters(double mean, double variance)Sets the parameters of a lognormal distribution to mean and variance. Note: these parameters are the actual mean and variance of the lognormal, not the underlying normal as in many other implementations.- Parameters:
mean- must be > 0variance- must be > 0
-
getMean
public final double getMean()
Description copied from interface:MeanIfcReturns the mean or expected value of a distribution
-
getMoment3
public final double getMoment3()
- Returns:
- the 3rd moment
-
getMoment4
public final double getMoment4()
- Returns:
- the 4th moment
-
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
-
getNormal
public final Normal getNormal()
Provides a normal distribution with correct parameters as related to this lognormal distribution- Returns:
- The Normal distribution
-
getNormalMean
public final double getNormalMean()
The mean of the underlying normal- Returns:
- mean of the underlying normal
-
getNormalVariance
public final double getNormalVariance()
The variance of the underlying normal- Returns:
- variance of the underlying normal
-
getNormalStdDev
public final double getNormalStdDev()
The standard deviation of the underlying normal- Returns:
- standard deviation of the underlying normal
-
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 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
-
pdf
public final double pdf(double x)
Description copied from interface:PDFIfcReturns the f(x) where f represents the probability density function for the distribution. Note this is not a probability.
-
getSkewness
public final double getSkewness()
Gets the skewness of the distribution- Returns:
- the skewness
-
getKurtosis
public final double getKurtosis()
Gets the kurtosis of the distribution- Returns:
- the kurtosis
-
setParameters
public final void setParameters(double[] parameters)
Sets the parameters for the distribution mean = parameters[0] and variance = parameters[1]- Specified by:
setParametersin interfaceParametersIfc- Parameters:
parameters- an array of doubles representing the parameters for the distribution
-
getParameters
public final double[] getParameters()
Gets the parameters for the distribution- Specified by:
getParametersin interfaceParametersIfc- Returns:
- Returns an array of the parameters for the distribution
-
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)]
-
getRandomVariable
public final RVariableIfc getRandomVariable(RNStreamIfc rng)
- Specified by:
getRandomVariablein interfaceGetRVariableIfc- Overrides:
getRandomVariablein classDistribution- Parameters:
rng- the stream to use- Returns:
- a random variable
-
-