1
y = 1.*randn(1000,1) + 5

Now the mean is 5 and the variance is 1. But it's still possible to get a number out of range(0,10)

SecretAgentMan
  • 2,856
  • 7
  • 21
  • 41
Jiaxin Li
  • 11
  • 3
  • By definition of the distribution, any value is possible with a certain small probability. Are you looking for a truncated normal distribution? https://en.wikipedia.org/wiki/Truncated_normal_distribution – Daniel Feb 02 '20 at 19:54
  • Thanks a lot for your help! Yes, I'm looking for a truncated normal distribution. I'm not sure if I can realize it with randn function, – Jiaxin Li Feb 02 '20 at 20:13
  • Once you have the name, it is actually easy to find. The question was previously asked: https://stackoverflow.com/q/18099201/2732801 – Daniel Feb 02 '20 at 20:33

0 Answers0