This repository has been archived on 2021-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
scientificComputing/statistics/code/correlations.m

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 )