[R] identifying and drawing from T distribution

Joshua Wiley jwiley.psych at gmail.com
Sat Mar 16 03:20:58 CET 2013


Hi Ivo,

Try something like this:

rt(1e5, df = 2.6, ncp = (1 - 0) * sqrt(2.6 + 1)/2)

The NCP comes from the mean, N, and SD.  See ?rt

Cheers,

Josh



On Fri, Mar 15, 2013 at 6:58 PM, ivo welch <ivo.welch at anderson.ucla.edu> wrote:
> dear R experts:
>
> fitdistr suggests that a t with a mean of 1, an sd of 2, and 2.6
> degrees of freedom is a good fit for my data.
>
> now I want to draw random samples from this distribution.    should I
> draw from a uniform distribution and use the distribution function
> itself for the transform, or is there a better way to do this?   there
> is a non-centrality parameter ncp in rt, but one parameter ncp cannot
> subsume two (m and s), of course.  my first attempt was to draw
> rt(..., df=2.63)*s+m, but this was obviously not it.
>
> advice appreciated.
>
> /iaw
>
> ----
> Ivo Welch (ivo.welch at gmail.com)
> http://www.ivo-welch.info/
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



--
Joshua Wiley
Ph.D. Student, Health Psychology
University of California, Los Angeles
http://joshuawiley.com/
Senior Analyst - Elkhart Group Ltd.
http://elkhartgroup.com



More information about the R-help mailing list