checkgbmpaths.m

来自「Numerical Methods In_Finance And Economi」· M 代码 · 共 12 行

M
12
字号
function PercErrors = CheckGBMPaths(S0, mu, sigma, T, Paths);
[NRepl, NTimes] = size(Paths);
NSteps = NTimes-1;
Tvet = (1:NSteps).*T/NSteps;
SampleMean = mean(Paths(:,2:NTimes));
TrueMean = S0 * exp(mu*Tvet);
RelErrorM = abs((SampleMean - TrueMean)./TrueMean);
SampleVar = var(Paths(:,2:(1+NSteps)));
TrueVar =  S0^2 * exp(2*mu*Tvet) .* (exp((sigma^2) * Tvet) - 1) ;
RelErrorV = abs((SampleVar - TrueVar)./TrueVar);
PercErrors = 100*[RelErrorM', RelErrorV'];

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?