how to get random value from normal distribution mean zero standard deviation 1

15 views (last 30 days)
I would like to get random value from normal distributionnormal distribution mean zero standard deviation 1.

Answers (1)

Omer Yasin Birey
Omer Yasin Birey on 4 Feb 2019
Edited: Omer Yasin Birey on 4 Feb 2019
normrnd(0,1)
or
randn(5,1)% 5 is just an example it will create 5*1 matrix adjust the value
  3 Comments
Guillaume
Guillaume on 4 Feb 2019
Reply by Omer Yasin Birey also moved here
Hi Khaled, firstly probably you are trying with low values as parameters such as
randn(5,1)%5 is low here
If you increase this value you probably will see values besides -1 to 1. However, you want mean 0 and std 1, the normal distribution is a kind of distribution, where almost half of the values should be greater than mean and the other almost half should be lower than mean. So with these mean and std values it is not likely to go far away from mean with normally random values. The randomly distributed values will end up positive or negative side of 0 (since it is the mean) and we prefer the distance 1(since it is the std). And the average of total distribution should converge 0. Therefore -1 and 1 is quite likely to happen here. If you want to test normal distribution, you can use other mean and std values such as.
5 + 10*randn(1000,1); % 5 is mean, 10 is std here
In this example most of them will be between -5 to 15. Since the mean is 5 std is 10 here. But of course some nasty boys will go out from this boundries. But we talk about the generalizations here.
Guillaume
Guillaume on 4 Feb 2019
"but i get some values more than 1 and less than -1"
You need to go back and read the definition of a normal distribution and the definition of standard deviation.
A distribution of mean 0 and standard deviation 1 must have values outside of the range [-1,1], otherwise the standard deviation must be less than 1.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!