Package jsl.utilities.distributions
Class StudentT
- java.lang.Object
-
- jsl.utilities.distributions.Distribution
-
- jsl.utilities.distributions.StudentT
-
- All Implemented Interfaces:
ControllableIfc,CDFIfc,ContinuousDistributionIfc,DistributionFunctionIfc,DistributionIfc,DomainIfc,InverseCDFIfc,MeanIfc,PDFIfc,VarianceIfc,GetNameIfc,IdentityIfc,NewInstanceIfc,ParametersIfc,GetRVariableIfc
public class StudentT extends Distribution implements ContinuousDistributionIfc, InverseCDFIfc, GetRVariableIfc
The Student T distribution See http://www.mth.kcl.ac.uk/~shaww/web_page/papers/Tdistribution06.pdf See http://en.wikipedia.org/wiki/Student's_t-distribution This implementation limits the degrees of freedom to be greater than or equal to 1.0 Bailey's acceptance rejection is used for sampling by default but inverse transform can be selected
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class jsl.utilities.distributions.Distribution
Distribution.RandomControls
-
-
Field Summary
Fields Modifier and Type Field Description static StudentTdefaultTA default instance for easily computing Student-T values-
Fields inherited from class jsl.utilities.distributions.Distribution
myId, myName
-
-
Constructor Summary
Constructors Constructor Description StudentT()Constructs a StudentT distribution with 1.0 degree of freedomStudentT(double dof)Constructs a StudentT distribution dof degrees of freedomStudentT(double[] parameters)Constructs a StudentT distribution with parameters[0] = degrees of freedomStudentT(double dof, java.lang.String name)Constructs a StudentT distribution dof degrees of freedom
-
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 doublegetCDF(double dof, double x)A convenience method that uses defaultT to return the value of the CDF at the supplied x This method has the side effect of changing the degrees of freedom defaultTdoublegetDegreesOfFreedom()IntervalgetDomain()doublegetIntervalFactor()Used in the binary search to set the search interval for the inverse CDF.static doublegetInvCDF(double dof, double p)A convenience method that uses defaultT to return the value of the inverse CDF at the supplied p This method has the side effect of changing the degrees of freedom for defaultTdoublegetMean()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.StudentTnewInstance()Returns a new instancedoublepdf(double x)Returns the f(x) where f represents the probability density function for the distribution.voidsetDegreesOfFreedom(double dof)Sets the degrees of freedom for the distributionvoidsetIntervalFactor(double factor)Used in the binary search to set the search interval for the inverse CDF.voidsetParameters(double[] parameters)Sets the parameters-
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
-
-
-
-
Field Detail
-
defaultT
public static final StudentT defaultT
A default instance for easily computing Student-T values
-
-
Constructor Detail
-
StudentT
public StudentT()
Constructs a StudentT distribution with 1.0 degree of freedom
-
StudentT
public StudentT(double[] parameters)
Constructs a StudentT distribution with parameters[0] = degrees of freedom- Parameters:
parameters- An array with the degrees of freedom
-
StudentT
public StudentT(double dof)
Constructs a StudentT distribution dof degrees of freedom- Parameters:
dof- degrees of freedom
-
StudentT
public StudentT(double dof, java.lang.String name)Constructs a StudentT distribution dof degrees of freedom- Parameters:
dof- degrees of freedomname- an optional name/label
-
-
Method Detail
-
newInstance
public final StudentT newInstance()
Description copied from interface:NewInstanceIfcReturns a new instance- Specified by:
newInstancein interfaceNewInstanceIfc- Specified by:
newInstancein classDistribution- Returns:
- the new instance
-
setDegreesOfFreedom
public final void setDegreesOfFreedom(double dof)
Sets the degrees of freedom for the distribution- Parameters:
dof- must be >= 1.0
-
getDegreesOfFreedom
public final double getDegreesOfFreedom()
- Returns:
- the degrees of freedom
-
getIntervalFactor
public final double getIntervalFactor()
Used in the binary search to set the search interval for the inverse CDF. The default addFactor is 6.0 The interval will be: start = Normal.stdNormalInvCDF(p) ll = start - getIntervalFactor()*getStandardDeviation(); ul = start + getIntervalFactor()*getStandardDeviation();- Returns:
- the factor
-
setIntervalFactor
public final void setIntervalFactor(double factor)
Used in the binary search to set the search interval for the inverse CDF. The default addFactor is 6.0 The interval will be: start = Normal.stdNormalInvCDF(p) ll = start - getIntervalFactor()*getStandardDeviation(); ul = start + getIntervalFactor()*getStandardDeviation();- Parameters:
factor- the factor
-
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
-
getParameters
public double[] getParameters()
Description copied from interface:ParametersIfcGets the parameters- Specified by:
getParametersin interfaceParametersIfc- Returns:
- Returns an array of the parameters
-
getMean
public double getMean()
Description copied from interface:MeanIfcReturns the mean or expected value of a distribution
-
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
-
pdf
public 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.
-
getCDF
public static double getCDF(double dof, double x)A convenience method that uses defaultT to return the value of the CDF at the supplied x This method has the side effect of changing the degrees of freedom defaultT- Parameters:
dof- the degrees of freedomx- the value to evaluate- Returns:
- the CDF value
-
getInvCDF
public static double getInvCDF(double dof, double p)A convenience method that uses defaultT to return the value of the inverse CDF at the supplied p This method has the side effect of changing the degrees of freedom for defaultT- Parameters:
dof- the degrees of freedomp- the value to evaluate- Returns:
- the inverse
-
cdf
public double cdf(double x)
Description copied from interface:CDFIfcReturns the F(x) = Pr{X <= x} where F represents the cumulative distribution function
-
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
-
getRandomVariable
public final RVariableIfc getRandomVariable(RNStreamIfc rng)
- Specified by:
getRandomVariablein interfaceGetRVariableIfc- Overrides:
getRandomVariablein classDistribution- Parameters:
rng- the stream to use- Returns:
- a random variable
-
-