# MATLAB: Random numbers

• Jan 27th 2009, 12:51 PM
agentsmith270288
MATLAB: Random numbers
I am trying to generate a sequence of 100 random numbers from N (0, 1) using the matlab command randn. I am completely new to matlab so I had a look at the documentation, however, I am still unclear as to how exactly to use the randn command. I understand that one of the parameters is the stream from which the random numbers are obtained and the other parameter is the matrix size.
• Jan 28th 2009, 02:17 AM
Constatine11
Quote:

Originally Posted by agentsmith270288
I am trying to generate a sequence of 100 random numbers from N (0, 1) using the matlab command randn. I am completely new to matlab so I had a look at the documentation, however, I am still unclear as to how exactly to use the randn command. I understand that one of the parameters is the stream from which the random numbers are obtained and the other parameter is the matrix size.

Basic operation should work, try

N=randn([1,100])

(iirc this will use a state set from the system clock to start the stream)

.
• Jan 28th 2009, 06:08 AM
agentsmith270288
MATLAB: random numbers
Thanks, I was doing something similar to this but wasn't sure if it was right. However, what if I wanted to compute random numbers from N(5,25) or any other distribution, how would that be done?
• Jan 28th 2009, 11:10 AM
Constatine11
Quote:

Originally Posted by agentsmith270288
Thanks, I was doing something similar to this but wasn't sure if it was right. However, what if I wanted to compute random numbers from N(5,25) or any other distribution, how would that be done?

rand([1.100])*5+5

or rather:

rand([1.100])*SD+mean

.