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 StudentT
defaultT
A 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 double
cdf(double x)
Returns the F(x) = Pr{X <= x} where F represents the cumulative distribution functionstatic 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 defaultTdouble
getDegreesOfFreedom()
Interval
getDomain()
double
getIntervalFactor()
Used in the binary search to set the search interval for the inverse CDF.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 defaultTdouble
getMean()
Returns the mean or expected value of a distributiondouble[]
getParameters()
Gets the parametersRVariableIfc
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.StudentT
newInstance()
Returns a new instancedouble
pdf(double x)
Returns the f(x) where f represents the probability density function for the distribution.void
setDegreesOfFreedom(double dof)
Sets the degrees of freedom for the distributionvoid
setIntervalFactor(double factor)
Used in the binary search to set the search interval for the inverse CDF.void
setParameters(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:NewInstanceIfc
Returns a new instance- Specified by:
newInstance
in interfaceNewInstanceIfc
- Specified by:
newInstance
in 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:ParametersIfc
Sets the parameters- Specified by:
setParameters
in interfaceParametersIfc
- Parameters:
parameters
- an array of doubles representing the parameters
-
getParameters
public double[] getParameters()
Description copied from interface:ParametersIfc
Gets the parameters- Specified by:
getParameters
in interfaceParametersIfc
- Returns:
- Returns an array of the parameters
-
getMean
public double getMean()
Description copied from interface:MeanIfc
Returns the mean or expected value of a distribution
-
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
-
pdf
public double pdf(double x)
Description copied from interface:PDFIfc
Returns 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:CDFIfc
Returns the F(x) = Pr{X <= x} where F represents the cumulative distribution function
-
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
-
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
-
-