israkir
israkir

Reputation: 2131

Generating a random matrix with independent elements

Let's say R is a mxn random matrix. How can generate R with each entry of R is independent and identically chosen from any distribution with mean zero and variance mu^2?

Upvotes: 0

Views: 441

Answers (1)

emarti
emarti

Reputation: 172

You probably want 'randn', which chooses entries from a Gaussian distribution with norm 1. To get a variance of mu^2, use

mu*randn(m,n)

For instance:

x=10*randn(1,1e5);var(x)

I get:

ans =  
99.8547

Mileage may vary. =)

Upvotes: 1

Related Questions