What is the difference between rand and randn in MATLAB ?
We have two functions in MATLAB namely rand() and randn() to generate random numbers. There exists a small difference between these two which lets us easy to use but complex to understand.
rand gives value from standard uniform distribution. That is they are in range [0,1].
randn gives value from standard normal distribution. A distribution with mean 0 and variance 1 is nothing but Standard Uniform Distribution. These are also in range [0,1]
In general we will use randn for generating random numbers.
If you enjoyed this post, make sure you subscribe to my RSS feed! Comments are encouraged
rand gives value from standard uniform distribution. That is they are in range [0,1].
randn gives value from standard normal distribution. A distribution with mean 0 and variance 1 is nothing but Standard Uniform Distribution. These are also in range [0,1]
In general we will use randn for generating random numbers.
If you enjoyed this post, make sure you subscribe to my RSS feed! Comments are encouraged