public Parameter[] WingCenterPara = new Parameter[4]; //ordre: cste, slope, put ordre 2, call ordre 2 public WingModel(double[,] data, double forwardPrice) { _data = data; _forwardPrice = forwardPrice; upSm = 0.5; //default value downSm = 0.5; _dataVolLogMoy = FittingModel.LogMoneynessVolData(_data, _forwardPrice); downCutoff = _dataVolLogMoy[0, 0]; UpCutoff = _dataVolLogMoy[_dataVolLogMoy.GetLength(0) - 1, 0]; InitWingParam();//ordre: cste, slope, put ordre 2, call ordre 2 var k = new Parameter(0); Parameter[] observedParameters = { k }; Func <double>[] Function = { () => WingCenterPara[0].Value + WingCenterPara[1].Value * k + Math.Min(1, Math.Truncate(Math.Exp(k))) * WingCenterPara[2].Value * k * k + (1 - Math.Min(1, Math.Truncate(Math.Exp(k)))) * WingCenterPara[3].Value * k * k }; // var LMregressor = new LevenbergMarquardt(Function, WingCenterPara, observedParameters, _dataVolLogMoy, 5);//for point of derivatives, regarder codeWWWfavouriteP WingCenterPara = LevenbergMarquardt.Compute(Function, WingCenterPara, observedParameters, _dataVolLogMoy, 5); // WingCenterPara = LMregressor._regressionParameters; interpolationLagrangeExt(); }
public static Parameter[] GsviAdjustedFit(double[,] data, double forwardPrice) { double[,] dataVarLogMon = FittingModel.LogMoneynessVarData(data, forwardPrice); Parameter[] SVIRawPara = InitSviAdjParam(dataVarLogMon);//ordre: a, b, rho, sigma, m var k = new Parameter(0); Parameter[] observedParameters = { k }; Func <double>[] regressionFunction = { () => SVIRawPara[0].Value + SVIRawPara[1].Value * (SVIRawPara[2].Value * (k - SVIRawPara[4].Value) + Math.Sqrt(Math.Pow((k - SVIRawPara[4].Value), 2) + Math.Pow(SVIRawPara[3].Value, 2))) }; return(LevenbergMarquardt.Compute(regressionFunction, SVIRawPara, observedParameters, dataVarLogMon, 5)); }
public static Parameter[] SviFit(double[,] data, double forwardPrice) { Parameter[] sVIRawPara = new Parameter[5]; double[,] _dataVarLogMon = LogMoneynessVarData(data, forwardPrice); sVIRawPara = InitSviParams(_dataVarLogMon);//ordre: a, b, rho, sigma, m var k = new Parameter(0); Parameter[] observedParameters = { k }; Func <double>[] regressionFunction = { () => sVIRawPara[0].Value + sVIRawPara[1].Value * (sVIRawPara[2].Value * (k - sVIRawPara[4].Value) + Math.Sqrt(Math.Pow((k - sVIRawPara[4].Value), 2) + Math.Pow(sVIRawPara[3].Value, 2))) }; return(LevenbergMarquardt.Compute(regressionFunction, sVIRawPara, observedParameters, _dataVarLogMon, 5)); }
public static Parameter[] GsviFit(double[,] data, double forwardPrice) { Parameter[] GSVIPara = new Parameter[6]; double[,] dataVarLogMon = LogMoneynessVarData(data, forwardPrice); GSVIPara = InitGsviParams(dataVarLogMon);//ordre: a, b, rho, sigma, m var k = new Parameter(0); Parameter[] observedParameters = { k }; Func <double>[] regressionFunction = { () => GSVIPara[0].Value + GSVIPara[1].Value * (GSVIPara[2].Value * ((k - GSVIPara[4].Value) / Math.Pow(GSVIPara[5].Value, Math.Abs(k - GSVIPara[4].Value)) - GSVIPara[4].Value) + Math.Sqrt(Math.Pow(((k - GSVIPara[4].Value) / Math.Pow(GSVIPara[5].Value, Math.Abs(k - GSVIPara[4].Value)) - GSVIPara[4].Value), 2) + Math.Pow(GSVIPara[3].Value, 2))) }; return(LevenbergMarquardt.Compute(regressionFunction, GSVIPara, observedParameters, dataVarLogMon, 5)); }