Random Numbers with Gaussian and Uniform Distributions in matlab

Yuseferi picture Yuseferi · Dec 12, 2012 · Viewed 36.7k times · Source

I want generate a number in Gaussian and Uniform distributions in matlab. I know this function randi and rand() but all of them are in normal (Gaussian) distribution. How can a generate a random number in uniform distribution?

Answer

supyo picture supyo · Dec 12, 2012

Use rand(dimensions) for a Uniform Distribution between 0 and 1.

Use randn(dimensions) * sqrt(sigma) + mu for a Gaussian Distribution with a mean of mu and variance of sigma.

Uniform Distribution

Normal Distribution