mvlognrnd.m

Revision 1 - 3/16/07 at 12:43 pm by e2holmes

Back to revision history for mvlognrnd.m
This file is part of the project PVA estimation code
function ms = mvlognrnd(nvars, means, vars, corr)
%mvlognrnd returns nvars LOGNORMAL with means, vars, and correlation

% means is the means of your random variable
if (length(means) == 1) means = means*ones(1,nvars); end
% vars is the variances of your ransom variables
if (length(vars) == 1) vars=vars*ones(1, nvars); end
% corr is the correlation coeffient for your random variables; at this point corr must be the same for all
means = zeros(1,nvars);
temp0 = repmat(sqrt(vars),[nvars 1]) .* repmat(sqrt(vars)',[1 nvars]);
temp1 = temp0 .* (corr*ones(nvars,nvars));
temp2 = temp0 .* ((1-corr)*eye(nvars,nvars));
varcovmatrix = (temp1+temp2);
ms = mvnrnd(means, varcovmatrix,1);
ms = exp(ms);
Sculpin 0.2 | xhtml | problems or comments? | report bugs