and i am trying to compute gaussian copula
Displays Nan in correlation result
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
I am finding the correlation between the generated random variable but the result is nan, can you please help me
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);
r2= norm_mean+sqrt(norm_var)*randn(1,N);
%normal distribution PDF
xPDF= normpdf(r1,norm_mean,sqrt(norm_var));
yPDF =normpdf(r2,norm_mean,sqrt(norm_var));
%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);
y2 = cdf(pd,r2);
%calculating correlation
rho= corr(r1,r2);
Respuestas (1)
Ameer Hamza
el 23 de Sept. de 2020
r1 and r2 shoule be column vectors in your case
rho= corr(r1(:),r2(:));
2 comentarios
Ameer Hamza
el 24 de Sept. de 2020
Both are correct syntax. You need to decide which one to use for this problem.
Ver también
Categorías
Más información sobre Copula Distributions and Correlated Samples en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!