Package jsl.utilities.distributions
Class Triangular
- java.lang.Object
-
- jsl.utilities.distributions.Distribution
-
- jsl.utilities.distributions.Triangular
-
- All Implemented Interfaces:
ControllableIfc,CDFIfc,ContinuousDistributionIfc,DistributionFunctionIfc,DistributionIfc,DomainIfc,InverseCDFIfc,MeanIfc,PDFIfc,VarianceIfc,GetNameIfc,IdentityIfc,NewInstanceIfc,ParametersIfc,GetRVariableIfc
public class Triangular extends Distribution implements ContinuousDistributionIfc, InverseCDFIfc, GetRVariableIfc
Represents the Triangular distribution with parameters - minimum value, maximum value and most likely value
-
-
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 Triangular()Constructs a Triangular distribution with min = 0.0, mode = 0.0, and max = 1.0Triangular(double[] parameters)Constructs a Triangular distribution with min = parameters[0], mode = parameters[1], max = parameters[2]Triangular(double min, double mode, double max)Constructs a Triangular distribution with min, mode, and maxTriangular(double min, double mode, double max, java.lang.String name)Constructs a Triangular distribution with min, mode, and max
-
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 functionstatic booleancheckParameters(double[] param)Returns true if the parameters are valid for the distribution min = param[0] mode = param[1] max = param[2]IntervalgetDomain()doublegetKurtosis()Gets the kurtosis of the distribution mu4/mu2^2, www.mathworld.wolfram.com/Kurtosis.html www.mathworld.wolfram.com/TriangularDistribution.htmldoublegetMaximum()doublegetMean()Returns the mean or expected value of a distributiondoublegetMinimum()doublegetMode()doublegetMoment3()doublegetMoment4()double[]getParameters()Gets the parameters for the distributionRVariableIfcgetRandomVariable(RNStreamIfc rng)doublegetSkewness()Gets the skewness of the distribution mu3/mu2^(3/2), www.mathworld.wolfram.com/Skewness.html www.mathworld.wolfram.com/TriangularDistribution.htmldoublegetVariance()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.TriangularnewInstance()Returns a new instancedoublepdf(double x)Returns the f(x) where f represents the probability density function for the distribution.voidsetParameters(double[] parameters)Sets the parameters for the distribution parameters[0] min The minimum value of the distribution parameters[1] mode The mode of the distribution parameters[2] max The maximum value of the distributionvoidsetParameters(double min, double mode, double max)Sets the minimum, most likely and maximum value of the triangular distribution to the private data members myMin, myMode and myMax resp throws IllegalArgumentException when the min >mode, min >= max, mode > max-
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
-
Triangular
public Triangular()
Constructs a Triangular distribution with min = 0.0, mode = 0.0, and max = 1.0
-
Triangular
public Triangular(double[] parameters)
Constructs a Triangular distribution with min = parameters[0], mode = parameters[1], max = parameters[2]- Parameters:
parameters- The array of parameters
-
Triangular
public Triangular(double min, double mode, double max)Constructs a Triangular distribution with min, mode, and max- Parameters:
min- The minimum value of the distributionmode- The mode of the distributionmax- The maximum value of the distribution
-
Triangular
public Triangular(double min, double mode, double max, java.lang.String name)Constructs a Triangular distribution with min, mode, and max- Parameters:
min- The minimum value of the distributionmode- The mode of the distributionmax- The maximum value of the distributionname- an optional label/name
-
-
Method Detail
-
newInstance
public final Triangular 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 min, double mode, double max)Sets the minimum, most likely and maximum value of the triangular distribution to the private data members myMin, myMode and myMax resp throws IllegalArgumentException when the min >mode, min >= max, mode > max- Parameters:
min- The minimum value of the distributionmode- The mode of the distributionmax- The maximum value of the distribution
-
checkParameters
public static boolean checkParameters(double[] param)
Returns true if the parameters are valid for the distribution min = param[0] mode = param[1] max = param[2]- Parameters:
param- the parameter array- Returns:
- true if the parameters are valid
-
getMinimum
public final double getMinimum()
- Returns:
- the minimum of the distribution
-
getMode
public final double getMode()
- Returns:
- the mode of the distribution
-
getMaximum
public final double getMaximum()
- Returns:
- the maximum of the distribution
-
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
-
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.
-
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
-
getKurtosis
public final double getKurtosis()
Gets the kurtosis of the distribution mu4/mu2^2, www.mathworld.wolfram.com/Kurtosis.html www.mathworld.wolfram.com/TriangularDistribution.html- Returns:
- the kurtosis
-
getSkewness
public final double getSkewness()
Gets the skewness of the distribution mu3/mu2^(3/2), www.mathworld.wolfram.com/Skewness.html www.mathworld.wolfram.com/TriangularDistribution.html- Returns:
- the skewness
-
setParameters
public void setParameters(double[] parameters)
Sets the parameters for the distribution parameters[0] min The minimum value of the distribution parameters[1] mode The mode of the distribution parameters[2] max The maximum value of the distribution- Specified by:
setParametersin interfaceParametersIfc- Parameters:
parameters- an array of doubles representing the parameters for the distribution
-
getParameters
public double[] getParameters()
Gets the parameters for the distribution- Specified by:
getParametersin interfaceParametersIfc- Returns:
- Returns an array of the parameters for the distribution
-
getRandomVariable
public final RVariableIfc getRandomVariable(RNStreamIfc rng)
- Specified by:
getRandomVariablein interfaceGetRVariableIfc- Overrides:
getRandomVariablein classDistribution- Parameters:
rng- the stream to use- Returns:
- a random variable
-
-