0

How can I create a vector x in Matlab that has values between 0.8 and 1.2, randomly sampled from a: 1. Uniform 2. Normal distribution?

There are a lot of functions dealing with distributions, but I'm having trouble using them properly.

Vidak
  • 1,083
  • 14
  • 29
  • 2
    You need `rand` for uniform distribution, and `randn` for normal distribution. However, any normal distribution is unbounded, so "normal distrbution" and "0.8 and 1.2" are incompatible requirements – Luis Mendo Jun 15 '15 at 15:38

1 Answers1

1

So, you can use this, for example:

y = 0.8 + rand*0.4;

this will generate random number between 0.8 and 1.2. because rand creates uniform distribution I believe that rand*0.4 creates the same ;)

Mikhail_Sam
  • 10,602
  • 11
  • 66
  • 102