u********h 发帖数: 146 | 1 代码很简单,计算vanilla call price如下,
但问题是代码中这个likehoodratio到底是怎么得出来的啊?看了看paul glasserman的
书上的likehoodratio算出来的和这个明显不同啊。
但是用这段代码算出来的东西是varaince小了并且结果也精确了,
求各位大侠帮忙解释一下如何计算的这个likehoodratio,或者给一点提示或者给点
reference也行啊
小弟先谢过了
double MonteCarlo2(const PayOff& thePayOff, double Expiry, double Spot,
double Vol, double r, double Strike, unsigned long NumberOfPaths)
{
double variance=Vol*Vol*Expiry;
double rootVariance=sqrt(variance);
double itoCorrection=-0.5*variance;
double drift_impsampling=log(Strike/Spot)+r*Expiry+itoCorrection;
double beta=r*Expiry+itoCorrection;
double alpha=log(Strike/Spot)+r*Expiry+itoCorrection;
double thisSpot;
double runningSum=0;
for(unsigned long i=0; i
{
double thisGaussian=GetOneGaussianByBoxMuller();
double X = drift_impsampling+rootVariance*thisGaussian;
thisSpot=Spot*exp(X);
double likelihoodratio=exp(-1*(2*(alpha-beta)*X-alpha*alpha+beta*beta)
/(2*variance));
double thisPayOff=thePayOff(thisSpot)*likelihoodratio;
runningSum+=thisPayOff;
}
double mean=runningSum/NumberOfPaths;
mean*=exp(-r*Expiry);
return mean;
} |
|