10 lines
200 B
Matlab
10 lines
200 B
Matlab
n = 1000;
|
|
x = randn(n, 1);
|
|
z = randn(n, 1);
|
|
y = x.^2 + 0.5*z;
|
|
scatter(x, y)
|
|
cov([x y])
|
|
r = corrcoef([x y])
|
|
text(-2, 8, sprintf('r=%.2f', r(1, 2)))
|
|
savefigpdf(gcf, 'nonlinearcorrelation.pdf', 15, 10);
|