Difference rand and randn command matlab

  • Thread starter Thread starter eltrinco
  • Start date Start date
  • Tags Tags
    Difference Matlab
Click For Summary
The rand command in MATLAB generates a matrix of pseudo-random numbers uniformly distributed between 0 and 1, while randn produces a matrix of pseudo-random numbers that follow a normal distribution with a mean of zero and a variance of one. Both commands accept similar arguments for matrix dimensions. Users can explore their functionalities further by typing "help rand" and "help randn" in the MATLAB command window. Visualizing the output by plotting the generated vectors can help clarify their differences. Understanding these distinctions is essential for proper application in simulations and statistical analysis.
eltrinco
Messages
6
Reaction score
0
i am confused between when to use rand and randn . can someone explain to me please?
 
Physics news on Phys.org
Both are pseudo-random number generators.
http://www.mathworks.com/help/matlab/random-number-generation.html

type "help rand" and "help randn" for a description.

Code:
rand()
Return a matrix with random elements uniformly distributed 
on the interval (0, 1).  The arguments are handled the same 
as the arguments for `eye'.

randn() 
Return a matrix with normally distributed pseudo-random 
elements having zero mean and variance one.  The arguments 
are handled the same as the arguments for `rand'.

You should be able to see the result by filling a vector with them and plotting.
 
  • Like
Likes 1 person

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 7 ·
Replies
7
Views
2K
Replies
3
Views
29K
  • · Replies 10 ·
Replies
10
Views
4K
  • · Replies 10 ·
Replies
10
Views
2K
Replies
8
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
15
Views
3K
Replies
3
Views
2K