如何在 Matlab 中从高斯 Copula 生成条件分布?
How to generate Conditional distribution from Gaussian Copula in Matlab?
Matlab 有一个从 copula 模拟的内置函数:copularnd
我需要一个条件高斯 Copula。
我有另一个用户对 Clayton Copula 的建议:
Clayton Copula Sampling
代码是:
任何人都可以举例说明如何使用 GAUSSIAN Copula?
进行编码
%% 使用条件 cdf 模拟 Clayton copula
%Example for theta=4
n=3000;
theta=5;
u=rand(1,n);
y=rand(1,n);
v=((y.^(1/(1+theta)).*u).^(-theta)+1-u.^(-theta)).^(-1/theta);
x1=norminv(u);
x2=norminv(v);
plot(x1,x2,'.')
我刚找到 this code:
%%Simulations of bivariate Gaussian copulas
%Example for rho=0.5
n=30000;
rho=0.5;
x1=norminv(rand(1,n));
x2=norminv(rand(1,n));
X = [x1; x2];
C = [1, rho; rho,1]; %2x2 Correlation matrix
cholesky = chol(C,'lower'); %lower triangular matrix of C using Cholesky decomposition
Copsims = cholesky*X;
c1 = Copsims(1,:);
c2 = Copsims(2,:);
plot(c1,c2,'.')
corrcoef(c1,c2) %check for empirical rho, not on point the initial rho because of sampling error
Matlab 有一个从 copula 模拟的内置函数:copularnd
我需要一个条件高斯 Copula。
我有另一个用户对 Clayton Copula 的建议:
Clayton Copula Sampling
代码是:
任何人都可以举例说明如何使用 GAUSSIAN Copula?
进行编码%% 使用条件 cdf 模拟 Clayton copula
%Example for theta=4
n=3000;
theta=5;
u=rand(1,n);
y=rand(1,n);
v=((y.^(1/(1+theta)).*u).^(-theta)+1-u.^(-theta)).^(-1/theta);
x1=norminv(u);
x2=norminv(v);
plot(x1,x2,'.')
我刚找到 this code:
%%Simulations of bivariate Gaussian copulas
%Example for rho=0.5
n=30000;
rho=0.5;
x1=norminv(rand(1,n));
x2=norminv(rand(1,n));
X = [x1; x2];
C = [1, rho; rho,1]; %2x2 Correlation matrix
cholesky = chol(C,'lower'); %lower triangular matrix of C using Cholesky decomposition
Copsims = cholesky*X;
c1 = Copsims(1,:);
c2 = Copsims(2,:);
plot(c1,c2,'.')
corrcoef(c1,c2) %check for empirical rho, not on point the initial rho because of sampling error