Distributions of random numbers of functions rand and randn

I want to know what distribution the rand function and the randn function have. In the documentation, I read that the rand function has an equiprobable distribution, and the randn normal function. Everywhere they write differently

My task is to generate pseudo-random numbers in the range from -0.1 to 0.1, equally distributed. I don't know what matlab function I can use.

It is important to have an equiprobable distribution, not a normal one (aka Gaussian).

2

1 Answer

From the documentation:

  • rand() returns a single uniformly distributed random number in the interval (0,1).
  • randn() returns a random scalar drawn from the standard normal distribution.

So to generate a random number uniformely distributed on (-0.1, 0.1) you can use

y = rand() * 0.2 - 0.1 

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

You Might Also Like