本文整理汇总了C#中IFunction.Partial方法的典型用法代码示例。如果您正苦于以下问题:C# IFunction.Partial方法的具体用法?C# IFunction.Partial怎么用?C# IFunction.Partial使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IFunction
的用法示例。
在下文中一共展示了IFunction.Partial方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LocVolMatrixFromImpliedVol
private Matrix LocVolMatrixFromImpliedVol(CallPriceMarketData Hdataset, IFunction impVol, out Vector locVolMat, out Vector locVolStr)
{
int nmat = calibrationSettings.LocalVolatilityMaturities;
int nstrike = calibrationSettings.LocalVolatilityStrikes;
double lastMat = Hdataset.Maturity[Range.End];
double lastStr = Hdataset.Strike[Range.End];
locVolMat = Vector.Linspace(Hdataset.Maturity[0], lastMat, nmat);
locVolStr = Vector.Linspace(Hdataset.Strike[0], lastStr, nstrike);
Matrix locVolMatrix = new Matrix(nmat, nstrike);
Integrate integrate = new Integrate(this);
double sigma, dSigmadk, num, y, den, avgGrowthRate;
Vector x = new Vector(2);
for (int i = 0; i < nmat; i++)
{
avgGrowthRate = integrate.AdaptLobatto(0.0, locVolMat[i]);
int j = 0;
x[0] = locVolMat[i];
x[1] = locVolStr[j];
sigma = impVol.Evaluate(x);
dSigmadk = impVol.Partial(x, 1);
num = Math.Pow(sigma, 2) + 2.0 * sigma * x[0] * impVol.Partial(x, 0);
den = 1.0;
locVolMatrix[i, j] = Math.Sqrt(num / den);
// The rest of the cycle.
for (j = 1; j < nstrike; j++)
{
x[1] = locVolStr[j];
sigma = impVol.Evaluate(x);
dSigmadk = impVol.Partial(x, 1);
num = Math.Pow(sigma, 2) + 2.0 * sigma * x[0] *
(impVol.Partial(x, 0) + avgGrowthRate * x[1] * dSigmadk);
y = Math.Log(locVolStr[j] / Hdataset.S0) + avgGrowthRate;
den = System.Math.Pow(1.0 - x[1] * y * dSigmadk / sigma, 2) + x[1] * sigma * x[0] *
(dSigmadk - 0.25 * x[1] * sigma * x[0] * dSigmadk * dSigmadk + x[1] * impVol.Partial2(x, 1));
locVolMatrix[i, j] = Math.Sqrt(num / den);
}
}
return locVolMatrix;
}