0

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

Luis Mendo
113k13 gold badges80 silver badges154 bronze badges
asked Mar 5, 2015 at 15:13
13
  • That's right. Looks like you have this nailed. Commented Mar 5, 2015 at 15:17
  • 2
    I'd only add a sqrt: r6=10+sqrt(1)*randn(10000,1);. Of course with 1it makes no difference; I mean the general case Commented Mar 5, 2015 at 15:18
  • @LuisMendo Good point, overlooked that and the OP maybe too! Commented Mar 5, 2015 at 15:19
  • 1
    No. r6=10+1*rand(10000,1) would give you a uniform RV (not Gaussian) with std equal to 1/sqrt(12) (not 1) Commented Mar 5, 2015 at 15:26
  • 1
    Why: just compute the variance of a pdf which is 1 in [0 1] and 0 outside that interval. Or see here. To generate uniform random numbers with mean 10 and variance 1: r6=10+sqrt(12)*(rand(10000,1)-.5). I'll let you figure out why this is so :-) Commented Mar 5, 2015 at 15:32

1 Answer 1

3

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
answered Mar 5, 2015 at 15:17
Sign up to request clarification or add additional context in comments.

1 Comment

@Jason Also note that 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.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.