\Header{TDist}{The Student t Distribution}
\alias{dt}{TDist}
\alias{pt}{TDist}
\alias{qt}{TDist}
\alias{rt}{TDist}
\keyword{distribution}{TDist}
\begin{Usage}
\begin{verbatim}
dt(x, df)
pt(q, df, ncp=0)
qt(p, df)
rt(n, df)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\texttt{x,q}] vector of quantiles.
\item[\texttt{p}] vector of probabilities.
\item[\texttt{n}] number of observations to generate.
\item[\texttt{df}] degrees of freedom.
\item[\texttt{ncp}] non-centrality parameter \eqn{\delta}{};
currently \texttt{ncp <= 37.62}.
\end{ldescription}
\end{Arguments}
\begin{Description}
These functions provide information about the t distribution with
\texttt{df} degrees of freedom (and optional noncentrality parameter
\texttt{ncp}).  \texttt{dt} gives the density, \texttt{pt}
gives the distribution function, \texttt{qt} gives the quantile function
and \texttt{rt} generates random deviates.\end{Description}
\begin{Details}
The \eqn{t}{} distribution with \texttt{df} \eqn{= n}{} degrees of freedom
has density 
\deqn{
f(x) = \frac{\Gamma ((n+1)/2)}{\sqrt{\pi n} \Gamma (n/2)}
(1 + x^2/n)^{-(n+1)/2}
}{f(x) = Gamma((n+1)/2) / (sqrt(n pi) Gamma(n/2)) (1 + x^2/n)^-((n+1)/2)}
for all real \eqn{x}{}.

The general \emph{non-central} \eqn{t}{}
with parameters \eqn{(\nu,\delta)}{(df,Del)} \texttt{= (df, ncp)}
is defined as a the distribution of 
\eqn{T_{\nu}(\delta) := \frac{U + \delta}{\chi_{\nu}/\sqrt{\nu}}}{T(df,Del) := (U + Del) / (Chi(df) / sqrt(df)) }
where \eqn{U}{} and \eqn{\chi_{\nu}}{Chi(df)}  are independent random
variables, \eqn{U \sim {\cal N}(0,1)}{U \~ N(0,1)}, and
\eqn{\chi^2_\nu}{Chi(df)^2} 
is chi-squared, see \texttt{\Link{pchisq}}.

The most used applications are power calculations for \eqn{t}{}-tests:\\{}
Let \eqn{T= \frac{\bar{X} - \mu_0}{S/\sqrt{n}}}{T= (mX - m0) / (S/sqrt(n))}
where
\eqn{\bar{X}}{mX} is the \texttt{\Link{mean}} and \eqn{S}{} the sample standard
deviation (\texttt{\Link{sd}}) of \eqn{X_1,X_2,\dots,X_n}{} which are i.i.d.
\eqn{       N(\mu,\sigma^2)}{N(mu,sigma^2)}.
Then \eqn{T}{} is distributed as non-centrally \eqn{t}{} with
\texttt{df}\eqn{= n-1}{} 
degrees of freedom and \bold{n}on-\bold{c}entrality \bold{p}arameter
\texttt{ncp}\eqn{= \mu - \mu_0}{= mu - m0}.\end{Details}
\begin{References}
Lenth, R. V. (1989). \emph{Algorithm AS 243} --
Cumulative distribution function of the non-central \eqn{t}{} distribution,
\emph{Appl.\ Statist.} \bold{38}, 185--189.\end{References}
\begin{SeeAlso}
\texttt{\Link{df}} for the F distribution.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
1 - pt(1:5, df = 1)
qt(.975, df = c(1:10,20,50,100,1000))

tt <- seq(0,10, len=21)
ncp <- seq(0,6, len=31)
ptn <- outer(tt,ncp, function(t,d) pt(t, df = 3, ncp=d))
image(tt,ncp,ptn, zlim=c(0,1),main=t.tit <- "Non-central t - Probabilities")
persp(tt,ncp,ptn, zlim=0:1, r=2, phi=20, theta=200, main=t.tit)
\end{ExampleCode}
\end{Examples}

