Exercise Set 1, Question 1

Matlab code:

X=ones(100000,1);
for i=2:length(X)
    X(i)=mod(8121*X(i-1)+28411,134456);
end
Y=X/134456;
hist(Y,100)

rho=zeros(100,1);
for j=1:100
    rho(j)=corr(X(1:99900),X((1+j):(99900+j)));
end
rho

mu=zeros(100,1);
for j=1:100
    mu(j)=corr(X(1:98900),X((1001+j):(99900+j)));
end
mu
Here is the histogram:

Distribution looks pretty uniform.

The numbers rho come out all between -0.0051 and 0.0067. The numbers mu all come out between -0.0061 and 0.0049 except mu(29) which is 0.0186. This is an example of the kind of unexpected long term correlation which can be found in sequences of psuedorandom numbers - but its effect is small.


Back to course home page
Back to my main teaching page
Back to my home page