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

7 ビュー (過去 30 日間)
Khaled Haj Taieb
Khaled Haj Taieb 2019 年 2 月 4 日
コメント済み: Guillaume 2019 年 2 月 4 日
I would like to get random value from normal distributionnormal distribution mean zero standard deviation 1.

回答 (1 件)

Omer Yasin Birey
Omer Yasin Birey 2019 年 2 月 4 日
編集済み: Omer Yasin Birey 2019 年 2 月 4 日
normrnd(0,1)
or
randn(5,1)% 5 is just an example it will create 5*1 matrix adjust the value
  3 件のコメント
Guillaume
Guillaume 2019 年 2 月 4 日
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 2019 年 2 月 4 日
"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.

サインインしてコメントする。

Community Treasure Hunt

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

Start Hunting!

Translated by