I'm a beginner in Matlab and I can't solve the problem below.
"Starting with z (0,1) Gaussian Random variable; generate 10000 random variables with mean 10, variance 1; call it r6 vector.
At first glance, I tried to write r6=10+1*randn(10000,1); but I am not sure whether it's correct or not. Any help will be appreciated. Many thanks
1 Answer 1
You can test whether you have the right mean and std deviation of your distribution after the fact with
mean(r6)
std(r6)
Note that as LuisMendo rightly points out you were issued the variance so you should make sure to take roots/square stuff as appropriate:
variance = std(r6)^2
1 Comment
mean(r6) and std(r6) are the sample mean / standard deviation, which are only approximations to the "true" mean / standard deviation. So you should expect some deviations in the obtained values; those deviations will of course diminish with the size of r6.
sqrt:r6=10+sqrt(1)*randn(10000,1);. Of course with1it makes no difference; I mean the general caser6=10+1*rand(10000,1)would give you a uniform RV (not Gaussian) with std equal to1/sqrt(12)(not1)r6=10+sqrt(12)*(rand(10000,1)-.5). I'll let you figure out why this is so :-)