Create a vector z with 1000 elements generated by the rand-function. The generated values must have a mean value of 0.5 (mean(0.5)). And a standard deviation of sqrt(1/100*12), (std(x)).

12 views (last 30 days)
So my task is to determine mean of an random vector to be set to 0.5. And the set standard deviation to be sqrt(1/100*12)
  2 Comments
Vetle Normann
Vetle Normann on 7 Sep 2018
so far i've searched around and written the following:
aa= sqrt(1/100*12) bb= 0.5
z = aa.*randn(1000,1)+bb;
mean = mean(yy) sdeviation = std(yy)
I don't get a consistent result from mean or sdeviation... Is this the closest i'm going to get to 0.5 and sqrt(1/100*12)?

Sign in to comment.

Accepted Answer

Cesar Antonio Lopez Segura
Hi all
Here the code:
mu = 0.5;
sigma = 0.3464;
z = mu + randn(1,1000)*sigma
STDcalculated = std( z )
MuCalculated = mean( z )
  3 Comments

Sign in to comment.

More Answers (1)

Torsten
Torsten on 7 Sep 2018
Edited: Torsten on 7 Sep 2018
0.5*(a+b) = 0.5
1/12*(b-a)^2 = 0.12
Solve for a and b.
This will give you the interval [a b] for which you must generate uniformly distributed random numbers.
Then you can use the rand-function as
z=a+(b-a)*rand(1000,1)
Best wishes
Torsten.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by