% This code produces QQ plots for two generated data sets and 
% log-returns using SP500 

% First data set (generated)

n=8000;
mu =0;
sigma2=8/6;

g1=normrnd(mu,sigma2,n,1);

figure(1)
qqplot(g1)
grid on
box off


% Second data set (generated)

v=5;
s = mu+sqrt((v-2)*sigma2/v)*trnd(v,n,1);

figure(2)
qqplot(s)
grid on
box off

% SP500 data
load SP500.mat;
data = SP500;
p = data(:,1);

p_0 = p(2:end,1);
p_1 = p(1:end-1,1);
r = log (p_0./p_1);

figure(3)
qqplot(r)
grid on
box off

