This repository has been archived on 2021-05-17. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
scientificComputing/statistics/code/correlations.m
2015-10-20 01:43:18 +02:00

15 lines
227 B
Matlab

n = 1000
x = randn( n, 1 );
y = randn( n, 1 ) + 0.2*x;
r = corr(x,y)
nsamples = 500;
rs = zeros( nsamples, 1 );
for i = 1:nsamples
xs = x(randi(n,n,1));
ys = x(randi(n,n,1));
rs(i) = corr(xs,ys);
end
hist( rs, 20 )