bshfun.m
来自「无忌卡尔曼粒子滤波」· M 代码 · 共 31 行
M
31 行
%/upf_demos/bshfun.m
function [y] = bshfun(x,u,t);
% PURPOSE : Measurement model function.
% INPUTS : - x: The evaluation point in the domain.
% OUTPUTS : - y: The value of the function at x.
% AUTHORS : Nando de Freitas (jfgf@cs.berkeley.edu)
% Rudolph van der Merwe (rvdmerwe@ece.ogi.edu)
% DATE : 10 March 2000
if nargin < 3, error('Not enough input arguments.'); end
[dim,np] = size(x);
y=zeros(2,np);
for j=1:np,
r = x(1,j); % Risk free interest rate.
sig = x(2,j); % Volatility.
S = u(1);
tm = u(2);
d1 = ( log(S) + (r+0.5*(sig^2))*tm ) / (sig * (tm^0.5));
d2 = d1 - sig * (tm^0.5);
% Compute call prices:
y(1,j) = S*normcdf(d1) - exp(-r*tm)*normcdf(d2);
% Compute put prices:
y(2,j) = - S*normcdf(-d1) + exp(-r*tm)*normcdf(-d2);
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?