random t distribution sample
显示 更早的评论
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!
采纳的回答
更多回答(8 个)
Fangjun Jiang
2011-9-17
0 个投票
Wayne King
2011-9-17
0 个投票
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
Wayne King
2011-9-17
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
Wayne King
2011-9-17
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
类别
在 帮助中心 和 File Exchange 中查找有关 Student's t Distribution 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!