Skip to content
Prev 311725 / 398503 Next

Student-t distributed random value generation within a confidence interval?

Thomas Schu <th.schumann <at> gmx.de> writes:
Perhaps: simulate more values than you need and take a subset:

allvals <- rt(1000,df=11)  
## 1000 samples is overkill: slightly more than 
##    500*(1.05) should be large enough
subvals <- (allvals[abs(allvals)<qt(0.975,df=11)])
vals <- m+subvals[1:500]*s/sqrt(n)

I'm subsetting before transforming, it seems slightly easier.