# Generate correlated random variables in a wider domain

9 views (last 30 days)
soheil radfar on 2 Jan 2020
Answered: Jeff Miller on 3 Jan 2020
Hi all,
I have a set of correlated data with rho = 0.0206. Each of two variable has a statistical distribution as follows (par = parameter):
WL = ('generalized extreme value',par1 = -0.4241, par2 = 0.6731, par3 = 1.4881)
Hs = ('Generalized Pareto', par1 = -0.0860, par2 = 0.2149, par3 = 1.7000)
when I ran my code to generate 100000 correlated samples, I see that data in X-axis has maximum limit of 3.15 and data in Y-axis has maximum limit of 3.4. I want to increase these limits to 6 but don't how!
Here is my code:
clear all
clc
Hs = RawData(:,2);
WL = RawData(:,1);
n = 100000; % Read number of simulations
rho=0.0206; % Calculate correlation parameter
ro=[1 rho;rho 1];
Z = mvnrnd([0 0], ro, n);
U = normcdf(Z);
WLinv=icdf('generalized extreme value',U(:,1),-0.4241, 0.6731, 1.4881);
Hsinv=icdf('Generalized Pareto',U(:,2),-0.0860, 0.2149, 1.7000);
X = [WLinv Hsinv];
[n1,ctr1] = hist(X(:,1),50);
[n2,ctr2] = hist(X(:,2),50);
plot(X(:,1),X(:,2),'.r'); hold on; plot(WL,Hs,'.b','markersize',12);
legend({'Simulated Data','Raw Data'},'Location','northwest','fontname','times','fontweight','bold','fontsize',10)
title('Monte-Carlo Data Simulation','fontname','times','fontweight','bold','fontsize',12)
ylabel('Significant Wave Height (Hs)','fontname','times','fontweight','bold','fontsize',12)
xlabel('Water Level (WL)','fontname','times','fontweight','bold','fontsize',12)
csvwrite('DataGen1.csv',X) % Write simulated data into an Excel file