Re: [R] Random numbers from noncentral t-distribution

From: Thomas Lumley <tlumley_at_u.washington.edu>
Date: Sat 01 Jul 2006 - 02:00:45 EST

On Fri, 30 Jun 2006, Long Qu wrote:

> Hi there:
>
> I'd thought these two versions of noncentral t-distribution are essentially the same:
> > qqplot(rt(1000,df=20,ncp=3),qt(runif(1000),df=20,ncp=3))
>
> But, the scales of the x-axis and the y-axis are quite different according to the QQ-plot.
>
> Did I make any mistakes somewhere?
>

No, I think we did.

We have
> rt

function (n, df, ncp = 0)
{

     if (ncp == 0)
         .Internal(rt(n, df))
     else rnorm(n, ncp)/(rchisq(n, df)/sqrt(df))
}

and the rchisq() in the denominator should be inside the sqrt().

         -thomas



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Sat Jul 01 03:25:36 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Sat 01 Jul 2006 - 04:15:57 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.