0
votes

I'd like to generate a matrix (m rows and n columns) whose entries are independently sampled from a zero-mean distribution, and each row is normalized to unit length. I know the function randn(m,n) of Matlab, but I'm not sure about "zero-mean" distribution and normalization. Can anybody help me? Thanks.

1
I think "zero-mean" just means that a given distribution has zero mean. Which still allows a continuum of possible distributions. And is the length in 2-norm? You probably need something like M=rand(m,n)-0.5; M=bsxfun(@rdivide,M,sqrt(sum(M.^2,2))). The elements are initially pseudo-random uniform in [-0.5, 0.5], then the rows are normalized. - Andras Deak

1 Answers

1
votes

If I understood your question correctly:

m=3; n=4;
M = randn([m n]);
M = bsxfun(@rdivide, M, sqrt(sum(M.*M,2))) %//divide each element by the magnitude of it's row

randn() fulfills zero-mean distribution as it samples from a standard normal distribution ~N(0,1).

By "each row normalized to unit length", Im assuming each row vector in M needs to be of unit length, so we divide each element by the magnitude of its corresponding row vector.