kb:qq_plots_matlab

qqplots.m
%% Heavy tails (t3)
 
nu = ones(1,100) * 3;
 
r = trnd(nu);
 
x = -5:0.01:5;
 
figure; hold on;
plot(x, tpdf(x, 3));
plot(x, normpdf(x));
 
legend("t_3", "N(0,1)");
 
figure;
 
qqplot(r);
 
%% Light tails (unif [0,1])
 
r = 2 .* rand(1,100) - 1;
 
figure; hold on;
plot(x, unifpdf(x, -1, 1));
plot(x, normpdf(x));
 
legend("Unif([-1,1])", "N(0,1)");
 
figure;
 
qqplot(r);
 
%% Right skewed (Exp(1))
 
mu = ones(1,100);
 
r = exprnd(mu);
 
figure; hold on;
plot(x, exppdf(x, 1));
plot(x, normpdf(x));
 
legend("Exp(1)", "N(0,1)");
 
figure;
 
qqplot(r);
 
%% Left skewed (-Exp(1))
 
mu = ones(1,100);
 
r = -exprnd(mu);
 
figure; hold on;
plot(x, exppdf(-x, 1));
plot(x, normpdf(x));
 
legend("-Exp(1)", "N(0,1)");
 
figure;
 
qqplot(r);
  • kb/qq_plots_matlab.txt
  • Last modified: 2024-04-30 04:03
  • by 127.0.0.1