clc;
clear;
S=10; %number of simulations
T=10000; %number of periods
K=0.5; %exercise price
N=10000; %number of put options to sell each period
Price=K*normcdf(K)+ exp(-K^2/2)/sqrt(2*pi); % fair price of the option
Profits=NaN(T,S);
for s=1:S
X=randn(T,1); %simulating standard normal random variables
Payoff=K-X;
Payoff(Payoff<0)=0; % put options payoff
Profits(:,s)=N*(Price.*ones(T,1)-Payoff); % time series of profits
end
histfit(Profits(:,1)) %Example of profits distribution
plot(cumsum(Profits)) %Evolutition of cumulative profits
The plot shows that it can take many periods before going bust.
4.
clc;
clear;
%Simulating Cauchy variates using probability integral transform
u=rand(1000);
lambda=2;
X=lambda*tan(pi.*(u-0.5));
m=mean(X);
histfit(m)
[h,p,jbstat,critval] = jbtest(m)
h=
p=
1.0000e-03
jbstat =
2.3811e+07
critval =
5.9282
Thus we reject the normal distribution at all levels of confidence.