Random vectors.
x=distfun_vectorrnd(r) x=distfun_vectorrnd(r,n) x=distfun_vectorrnd(r,n,sigma)
a list with d items describing the multivariate random variable (see below)
a 1-by-1 matrix of floating point integers, the number of rows in x (default n = 1)
a d-by-d matrix of doubles, the covariance matrix, symmetric, positive definite (default = identity)
a m-by-n matrix of doubles, the random numbers.
Generate a multivariate random vector given marginal and covariance matrix.
The covariance matrix sigma must have unit diagonal. Its non-diagonal terms must be in the range [0,1).
If sigma is not provided (default), then the multivariate sample is generated by direct simulation, considering that the dimensions are independent.
If sigma is provided, the algorithm produces a sample with Gaussian copula.
The variable r is a list of n items, where r(i) is a list which describes the i-th random variable. The first item in r(i) is a string, which is the short name of the distribution. The used map is defined by distfun_list.
Implementation notes
If sigma is provided, the algorithm is the following.
Generate Z=[Z1,...,Zd] with zero mean, and given covariance.
Compute U = [Phi(Z1),...,Phi(Zd)], where Phi is the standard normal cumulative distribution function.
Compute X = [Q1(U1),...,Qd(Ud)], where Qi is the quantile function of the i-th marginal.
sigma = [ 3.0 0.5 0.5 1.0 ] v1=list("unif",5,12) // Uniform(min=5,max=12) v2=list("norm",-5,7) // Normal(mean=-5,sigma=7) r=list(v1,v2) n=10 // Number of outcomes x=distfun_vectorrnd(r,sigma,n) // Graphical "test" (requires Stixbox) x=distfun_vectorrnd(r,sigma,1000); scf(); for i=1:4 subplot(2,2,i) rho=(i-1)/4; sigma = [1.0 rho;rho 1.0]; x=distfun_vectorrnd(r,1000,sigma); plot(x(:,1),x(:,2),"bo"); title("rho="+string(rho)); end scf(); subplot(1,2,1) histo(x(:,1)); title("Uniform(5,12)"); subplot(1,2,2) histo(x(:,2)); title("Normal(-5,7)"); | ![]() | ![]() |
http://web.ics.purdue.edu/~hwan/IE680/Lectures/Chap08Slides.pdf
http://fr.mathworks.com/help/stats/examples/simulating-dependent-random-variables-using-copulas.html