How to generate random variable from t distribution with mean and scale
Show older comments
So the question is
How can I take 1000 draws from univariate Student-t distributions with mean = 1.5, scale = 2 and
degrees of freedom nu = 3; 5; 10; 20; 30; 60
1 Comment
Fanqi Meng
on 7 Apr 2019
Answers (1)
Jeff Miller
on 8 Apr 2019
I don't see that your code is correct, because it does not take 1,000 draws from anything, which is what you said you want to do.
Actually, it is not clear what you mean by "univariate t-distribution with mean=1.5, scale=2" and any specific df value. Apparently you want a noncentral t-distribution, which is required to give you a nonzero mean. That distribution has a noncentrality parameter and a df parameter, but that is all--there is no separate scale parameter.
df = 10; % for example
noncentrality_guess = 0.8; % This will soon be adjusted to give the desired mean of 1.5.
myt = tNoncentral(df,noncentrality_guess); % Construct a noncentral t distribution with these parameters.
myt.EstMom(1.5,'fr'); % Adjust the noncentrality parameter to give a distribution mean of 1.5
randvals = myt.Random(1000,1); % Generate 1,000 draws from the adjusted noncentral t.
Categories
Find more on Noncentral 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!