[閒聊] 扣的
CH2 1
% Illustrates compound interest
dzero = 5; %期初資金
r = 0.15; % Compound interest rate
T = 5; % 5 year period
m = 60; % 60 months
for i = 1:m % let i months elapse
tval(i) = i/12; %time in years
d1(i) = dzero*((1+r*(tval(i)/i))^0.5)^i; %compound i times by model 2.8
d2(i) = dzero*((1+r*(tval(i)/i))^1.5)^i; %compound i times by model 2.9
end
trange = [0,tval];
drange1 = [dzero,d1];
drange2 = [dzero,d2];
plot(trange,drange1,'r*')
hold on
plot(trange,drange2,'blue*')
tcts = linspace(0,T,100);
dcts = dzero*exp(r*tcts);
plot(tcts,dcts,'blacko')
CH2 2
n=1000;
T=10;
St=linspace(0,60,n);
X=30;
RFR=0.05;
for i=1:n
c(i)=max(0,St(i)-X/(1+RFR)^T);%call之下界
c(n)=St(n);%令其邊界封閉
end
fill(St,c,'y')
CH3 1
%hw2 P3.1
dsig = 0.25;
dx = 0.5;
mu = 0;
[X,SIGMA] = meshgrid(-10:dx:10,1:dsig:5);
Z = exp(-(X-mu).^2./(2*SIGMA.^2))./sqrt(2*pi*SIGMA.^2);
subplot(2,2,1);
waterfall(X,SIGMA,Z);
xlabel('x');
ylabel('\sigma');
zlabel('f(x)') ;
title('waterfall');
subplot(2,2,2);
mesh(X,SIGMA,Z);
xlabel('x') ;
ylabel('\sigma');
zlabel('f(x)');
title('mesh');
subplot(2,2,3);
surf(X,SIGMA,Z);
xlabel('x') ;
ylabel('\sigma');
zlabel('f(x)');
title('surf');
subplot(2,2,4);
surfc(X,SIGMA,Z);
xlabel('x') ;
ylabel('\sigma');
zlabel('f(x)');
title('surfc');
CH4 2
%hw2 P3.2
dsigma =0.25;
dx = 0.5;
[X,SIGMA] = meshgrid(0:dx:20,1:dsigma:10);
LAMDA=1./SIGMA;
f=exp(-(LAMDA.*X));
waterfall(X,SIGMA,f);
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.114.135.206
推
03/16 13:12, , 1F
03/16 13:12, 1F
推
03/19 23:41, , 2F
03/19 23:41, 2F
→
03/20 01:06, , 3F
03/20 01:06, 3F
→
03/20 02:10, , 4F
03/20 02:10, 4F