www.gusucode.com > stats 源码程序 matlab案例代码 > stats/HigherDimensionCopulasExample.m
%% Higher Dimension Copulas %% Simulate data from a trivariate distribution with Gamma(2,1), Beta(2,2), and t5 marginals using a Gaussian copula % Copyright 2015 The MathWorks, Inc. n = 1000; Rho = [1 .4 .2; .4 1 -.8; .2 -.8 1]; rng('default') % for reproducibility U = copularnd('Gaussian',Rho,n); X = [gaminv(U(:,1),2,1) betainv(U(:,2),2,2) tinv(U(:,3),5)]; %% Plot the data subplot(1,1,1) plot3(X(:,1),X(:,2),X(:,3),'.') grid on view([-55, 15]) xlabel('X1') ylabel('X2') zlabel('X3') %% Compute the theoretical rank correlation tauTheoretical = 2.*asin(Rho)./pi %% Compute the sample rank correlations of the data tauSample = corr(X,'type','Kendall')