random t distribution sample
Show older comments
Hi!
I want to obtain a random sample of outcomes which follows a t student distribution given a mean and a std.
I have been able to create a sample of 1000 observations which follow normal dist. typing A=random('norm',mean,std,1000,1).
How should I do it for a t distribution?
Thanks in advance!
Accepted Answer
More Answers (8)
Fangjun Jiang
on 17 Sep 2011
0 votes
Wayne King
on 17 Sep 2011
0 votes
Hi, I think you want trnd or nctrnd if you have the Statistics Toolbox.
The central t-distribution is not parameterized by a mean and variance like a Gaussian distribution. The central t-distribution is only parameterized by the degrees of freedom.
If you want to generate a sample from a noncentral t-distribution, see
nctrnd
By using the noncentral t, you can get the mean to be nonzero.
Hope that helps,
Wayne
Ferran
on 17 Sep 2011
0 votes
Wayne King
on 17 Sep 2011
Hi, The central t-distribution is symmetric and has mean zero (as long as you have more than 1 degree of freedom). For low degrees of freedom, you are correct that the tails are wider than the standard normal, but that difference goes away as the degrees of freedom increase as you note.
Compare
tcdf(3,4)
normcdf(3,0,1)
tcdf(3,20)
The noncentral t-distribution is not symmetric. The asymmetry depends on the noncentrality parameter and the degrees of freedom.
You can see how the mean and variance depend on the noncentrality parameter and degrees of freedom here:
Wayne
Ferran
on 17 Sep 2011
0 votes
Wayne King
on 17 Sep 2011
R = nctrnd(100,2,100,1);
will give you a random sample of 100 samples from a noncentral t with a mean of 2 (essentially), but note that the standard deviation will be about 1 in that case.
Again, both the mean and the variance depend on both the noncentrality parameter and the degrees of freedom.
Wayne
Ferran
on 17 Sep 2011
0 votes
Ferran
on 18 Sep 2011
0 votes
Categories
Find more on Student's t Distribution in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!