random t distribution sample
Mostra commenti meno recenti
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!
Risposta accettata
Più risposte (8)
Fangjun Jiang
il 17 Set 2011
0 voti
Wayne King
il 17 Set 2011
0 voti
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
il 17 Set 2011
0 voti
Wayne King
il 17 Set 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
il 17 Set 2011
0 voti
Wayne King
il 17 Set 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
il 17 Set 2011
0 voti
Ferran
il 18 Set 2011
0 voti
Categorie
Scopri di più su Student's t Distribution in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!