mu=[1 2 3 4 5]';
sigma=[1 1 1 1 1]';
N=100; %Number of samples for each mu
R=normrnd(mu,sigma,?)
Using normrnd, is it possible to generate N samples for each mu value without a loop (such that R will be 5 by 100 matrix)?
I don't know normrnd.
With older randn, I would have used something like:
repmat(mu,N,1) + randn(N,length(mu))*diag(sigma)
EDIT
Ah, you want the transpose 5x100, it's
repmat(mu,1,N) + diag(sigma)*randn(length(mu),N)
bsxfun instead of repmat: bsxfun(@plus, mu, randn(N, numel(mu))*diag(sigma)); You can see a comprehensive survey in comparison of performance here: stackoverflow.com/questions/29719674/… - Generally bsxfun is faster and more efficient than using the equivalent code with repmat.