-
Notifications
You must be signed in to change notification settings - Fork 0
/
msftLevy.m
27 lines (25 loc) · 991 Bytes
/
msftLevy.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
M = flipud(msftus);
returns = M(2:end-1)./M(1:end-2) - 1;
msftMean = mean(returns);
msftStd = std(returns);
params = alpha_loglik(returns);
H = chi2gof(returns);
disp(sprintf('The optimizing value of alpha is: %d', params.alph));
disp(sprintf('The optimizing value of beta is: %d', params.bet));
disp(sprintf('The optimizing value of gamma is: %d', params.gamm));
disp(sprintf('The optimizing value of delta is: %d', params.delt));
disp(sprintf('Chi Squared Test result is %d', H));
x = -0.59:0.01:0.39;
yGauss = gaussmf(x,[msftStd msftMean]);
figure;
hold on;
[nlnBins, xout] = hist(returns, 600);
nlnBins = nlnBins./ max(nlnBins).*2.0;
bar(xout, nlnBins);
plotGauss = plot(x, yGauss);
set(plotGauss, 'Color', 'green', 'LineWidth',2)
yAlphaLevy = stblpdf(x, params.alph, params.bet, params.gamm, params.delt);
plotLevy = plot(x, yAlphaLevy./max(yAlphaLevy)); %normalize maximum to 1
set(plotLevy, 'Color', 'red', 'LineWidth',2);
xlabel('Gaussian vs Alpha Stable Levy for MSFT');
hold off;