English 中文(简体)
MATLAB: Pricing a 数字选项, Monte Carlo vs clear organic program?
原标题:MATLAB: Pricing a digital option, Monte Carlo vs. explicit integral formula?

我用MATLAB处理下列问题:

允许Z按原样分配,使Rn Z的平均值为米和差异。 让排泄物是一个消极的数字,是一个积极的不变。

我正试图计算预期值(删除I(Z<=c)表示该套指标功能(Z<=c))

E[Z^(eta+1) I(Z<=c)] = (1/sqrt(w)) 集成_0^c x^(eta) phi((ln x - m)/sqrt(w) dx,

where phi() denotes the probability distribution function of a standard normal random variable.

首先,我对Z进行了10 000次试验,将病媒的条目定在价值和价值上;c 至0, 提高到(eta+1)的力量,然后计算了这个数值。 这应当给我对预期价值的估计。

ST = random( Lognormal , m,w_sq,10000,1);
hlp = zeros(10000,1);
hlp(ST<=2) = ST(ST<=2);
hlp(hlp>0) = hlp(hlp>0).^(eta1+1); % 0^(eta1+1) gives infinity
mean(hlp)

For the integral I used the following code

tmpp = integral(@(x) x.^(eta1) .* normpdf((log(x)-m)/sqrt(w_sq),0,c);
tmpp / sqrt(w_sq(1))

Unfortunately the procedures lead to totally different results, although mathematically they should be they same.

整个事项是一部更大的法典的一部分,我使用综合版本将更加方便。 最初,我试图利用文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、文化、

谁能帮助?

问题回答

第一部法典

I guess the reason why you have unexpected result is when you are doing the calculations on hlp, you try to avoid 0 values, as 0^eta will blow up - and that is not wanted result, so you simply drop it. But in the last step, mean(hlp) will take all values in array hlp, including those 0 s. Try this:

mean(hlp(hlp>0)

My results fall in roughly 2.x with 10,000-point simulation, 2.3x ~ 2.4x with 1,000,000 points.

我错了。 你们的问题是,你使用的点太少。 试验10 000 000点,并将满足:

第二,我对你如何界定你的变量有问题。 (我没有足够的声誉来补充评论,因此,我在此指出) <代码>w_sq中的“sq”是指<代码>w的方括号? 由于根据 rel=“nofollow”random,这一论点应当是“sigma”,这是标准偏差。 把SD界定为差异的深层根源是自然的,我猜测这种差异是<条码>w<>。 然后,你就在第一部分做了正确的工作。

如果是的话,在您的法典第二部中,你为什么在<代码>w_sq上将<>sqrt(>? 你们是否意味着把差异的第四个根基带走? 从你对期望的定义来看,我认为这不正确。 请看一下。

另一方面,<代码>w_sq a 单一数字或阵列?

  • If it is a number -

<代码>tmpp / sqrt(w_sq(1))应当改为tmpp / sqrt(w_sq),尽管它们实际上并没有改变。

  • If it s an array -

You may want to put all codes in a for loop. The loop iterates over w_sq, each time it picks out one of the elements in the array (name the variable as say w_sq_elem), and let the rest of the code do things as if it is a single number.

Anyway, (log(x)-m)/sqrt(w_sq) and tmpp / sqrt(w_sq(1)) are telling different information on w_sq. The first one assumes it s a number, so the division can be simply a /, rather than ./. The second one indicates it s an array so you are picking its first element. But an array does not make sense here because, in my understanding, you are not dividing 10,000 points in x by 10,000 different variances.

m = 3;
w_sq = 2;
eta1 = -2;
ST = random( Lognormal ,m,w_sq,10000000,1);
hlp = zeros(10000000,1);
hlp(ST<=2) = ST(ST<=2);
hlp(hlp>0) = hlp(hlp>0).^(eta1+1); % 0^(eta1+1) gives infinity
mean(hlp)

tmpp = integral(@(x) x.^(eta1) .* normpdf((log(x)-m)/w_sq),0,2) ;
tmpp / w_sq

>> untitled

ans =

    0.2944


ans =

    0.2948

>> 




相关问题
MATLAB Solving equations problem

I want to solve these equations using MATLAB and I am sure there is a non zero solution. The equations are: 0.7071*x + 0.7071*z = x -0.5*x + 0.7071*y + 0.5*z = y -0.5*x - 0.7071*y +...

Difference between MATLAB s matrix notations

How do you read the following MATLAB codes? #1 K>> [p,d]=eig(A) // Not sure about the syntax. p = 0.5257 -0.8507 -0.8507 -0.5257 d = ...

preventing data from being freed when vector goes out of scope

Is there a way to transfer ownership of the data contained in a std::vector (pointed to by, say T*data) into another construct, preventing having "data" become a dangling pointer after the vector goes ...

Divide two polynomials using MATLAB

I want to divide p(x) by q(x) given that: p(x)=-5x^4+3x^2-6x q(x)=x^2+1 I tried: p=inline( -5*(x^4)+3*(x^2) , x ) p = Inline function: p(x) = -5*(x^4)+3*(x^2) q=inline( x^2+1 , x ) q = ...

matlab deals with Fibbonacci

The Fibonacci series is given as follows: 1, 2, 3, 5, 8, 13, 21, ... How can I write a script which calculates and prints the n-th Fibonacci term (for n>2), where n is inputed by the user. This ...

How do I plot lines between all points in a vector?

I have a vector containing some points in 2-D space. I want MATLAB to plot these points with lines drawn from every point to every other point. Basically, I want a graph with all vertices connected. ...

How do I create a string using a loop variable in MATLAB?

I have a loop like this: for i=1:no %some calculations fid = fopen( c:\out.txt , wt ); %write something to the file fclose(fid); end I want data to be written to different files like ...

热门标签