Info

This question is closed. Reopen it to edit or answer.

Please experts help me to check this code and comment if error please

1 view (last 30 days)
clear all;
clc;
N = 1000;
% standard normal distribution mean=0 and variance =1
norm_mean=0;
norm_var=1;
%generating random variable with standard normal distribution
r1= norm_mean+sqrt(norm_var)*randn(1,N)
figure;
hist(r1)
r2= norm_mean+sqrt(norm_var)*randn(1,N);
figure;
hist(r2)
%u= copularndn('Gaussian',r1,r2)
figure
scatterhist(r1,r2)
%normal distribution PDF
xPDF= normpdf(r1,norm_mean,sqrt(norm_var));
figure;
hist(xPDF)
yPDF =normpdf(r2,norm_mean,sqrt(norm_var));
figure;
hist(yPDF)
%calculate normal distribution cdf
pd = makedist('Normal',norm_mean,sqrt(norm_var));
%compute the cdf values for the standard normal distribution at the values
%in random variables
y1 = cdf(pd,r1);
figure;
hist(y1)
y2 = cdf(pd,r2);
figure;
hist(y2)
figure
scatterhist(y1,y2)
%calculating correlation
rho= corr(y1(:),y2(:)) %rho is correlation coefficient
%calculating Gaussian/Normal copula
u=copularnd('Gaussian',rho,N)
figure;
scatterhist(u(:,1),u(:,2))
[SL: formatted the code as code]

Answers (0)

This question is closed.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!