stats::Tdist -- the
T-distribution
Introductionstats::Tdist(x, v) computes the value
gamma((v+1)/2)/sqrt(PI*v)/gamma(v/2) * int(1/(1+u^2/v)^((v+1)/2), u=-infinity..x)
of the T-distribution with v degrees of freedom at the point x.
Call(s)stats::Tdist(x, v)
Parametersx |
- | an arithmetical expression. |
v |
- | the ``degrees of freedom'': a positive real value. |
ReturnsIf x is a real float and v is a constant real
value, then a floating point value is returned. If x is not
a real float and v is a positive integer, then an explicit
arithmetical expression is returned. In all other cases an unevaluated
call of stats::Tdist is returned.
Side
EffectsThe function is sensitive to the environment variable DIGITS, when the argument
x is a floating point number.
Related
Functionsgamma, stats::normal, stats::ChiSquare
DetailsPI/2 + sqrt(2),
exp(-2) etc., then we strongly recommend to use
stats::Tdist(float(x), v) rather than
float(stats::Tdist(x, v)). This avoids the overhead of the
intermediate symbolic result stats::Tdist(x, v). Cf.
example 3.
Example
1We compute the T-distribution with two degrees of freedom at the point x=0.5:
>> stats::Tdist(0.5, 2)
0.6666666667
Exact values are produced, if the first argument is exact and the second argument is a positive integer:
>> stats::Tdist(7/8, 2)
/ 1/2 1/2 \
1/2 | 1/2 7 128 177 |
2 | 2 + --------------- |
\ 1416 /
-------------------------------
4
Example
2We compute the T-distribution with three degrees of freedom with a symbolic argument. An explicit expression is returned, when the second argument is a positive integer:
>> stats::Tdist(x, 3)
/ / 1/2 \ \
| 1/2 | x 3 | |
| 1/2 3 arctan| ------ | |
1/2 | PI 3 x \ 3 / |
2 3 | ------- + ------------ + --------------------- |
| 4 / 2 \ 2 |
| | x | |
| 2 | -- + 1 | |
\ \ 3 / /
---------------------------------------------------------
3 PI
An unevaluated call is returned, if the second argument is not a positive integer:
>> stats::Tdist(x, 3/2)
stats::Tdist(x, 3/2)
>> diff(%, x)
1/2 1/2
PI 3
-----------------------------
/ 2 \5/4
2 | 2 x |
6 gamma(3/4) | ---- + 1 |
\ 3 /
Example
3We compute a floating point value via an intermediate exact result:
>> stats::Tdist(7/2, 20)
/ / 1/2
| 1/2 | 131072 5
| 46189 5 | ----------- +
\ \ 230945
1/2 1/2 \ \
3673429330353857549533184 80 129 | |
-------------------------------------- | | / 262144
294717325313003652346374945 / /
>> float(%)
0.9988724384
It is more efficient to compute this value by a direct call with a floating point argument:
>> stats::Tdist(float(7/2), 20)
0.9988724384