public static double PDFIntegration(double x, double alpha, double precision, ref object tempStorage) { if (alpha < 1) { GetAlt1GnParameter(x, alpha, out var factorp, out var facdiv, out var dev, out var logPdfPrefactor); var intg = new Alt1GnI(factorp, facdiv, logPdfPrefactor, alpha, dev); if (intg.IsMaximumLeftHandSide()) { return(intg.PDFIntegrate(ref tempStorage, precision)); } else { return(new Alt1GnD(factorp, facdiv, logPdfPrefactor, alpha, dev).Integrate(ref tempStorage, precision)); } } else { GetAgt1GnParameter(x, alpha, out var factorp, out var factorw, out var dev, out var logPdfPrefactor); var intg = new Agt1GnI(factorp, factorw, logPdfPrefactor, alpha, dev); if (intg.IsMaximumLeftHandSide()) { return(intg.Integrate(ref tempStorage, precision)); } else { return(new Agt1GnD(factorp, factorw, logPdfPrefactor, alpha, dev).Integrate(ref tempStorage, precision)); } } }
private static void CDFMethodForPositiveX(double x, double alpha, ref object tempStorage, double precision, out double integFromXZero, out double integFromXInfinity) { const double offs = 0.5; if (alpha < 1) { GetAlt1GnParameter(x, alpha, out var factorp, out var facdiv, out var dev, out var logPdfPrefactor); var inc = new Alt1GnI(factorp, facdiv, logPdfPrefactor, alpha, dev); if (inc.IsMaximumLeftHandSide()) { integFromXZero = inc.CDFIntegrate(ref tempStorage, precision) / Math.PI; integFromXInfinity = offs - integFromXZero; } else { integFromXInfinity = new Alt1GnD(factorp, facdiv, logPdfPrefactor, alpha, dev).CDFIntegrate(ref tempStorage, precision) / Math.PI; integFromXZero = offs - integFromXInfinity; } } else if (alpha == 1) { if (x <= 1) { integFromXZero = Math.Atan(x) / Math.PI; integFromXInfinity = offs - integFromXZero; } else { integFromXInfinity = Math.Atan(1 / x) / Math.PI; integFromXZero = offs - integFromXInfinity; } } else // if(alpha>1) { GetAgt1GnParameter(x, alpha, out var factorp, out var factorw, out var dev, out var logPdfPrefactor); var inc = new Agt1GnI(factorp, factorw, logPdfPrefactor, alpha, dev); if (inc.IsMaximumLeftHandSide()) { integFromXInfinity = inc.CDFIntegrate(ref tempStorage, precision) / Math.PI; integFromXZero = offs - integFromXInfinity; } else { integFromXZero = new Agt1GnD(factorp, factorw, logPdfPrefactor, alpha, dev).CDFIntegrate(ref tempStorage, precision) / Math.PI; integFromXInfinity = offs - integFromXZero; } } }
/// <summary> /// Special case for alpha>1 and gamma near to alpha-2 (i.e. gamma at the negative border). /// </summary> /// <param name="x"></param> /// <param name="alpha"></param> /// <param name="gamma"></param> /// <param name="aga"></param> /// <param name="temp"></param> /// <param name="precision"></param> /// <returns></returns> public static double PDFIntegralAgt1Gn(double x, double alpha, double gamma, double aga, ref object temp, double precision) { double factorp, factorw, dev, prefactor; GetAgt1GnParameterByGamma(x, alpha, gamma, aga, out factorp, out factorw, out dev, out prefactor); Agt1GnI intI = new Agt1GnI(factorp, factorw, prefactor, alpha, dev); double integrand; if (intI.IsMaximumLeftHandSide()) integrand = intI.Integrate(ref temp, precision); // IntegrateFuncExpMFuncInc(delegate(double theta) { return PDFCoreAgt1GnI(factorp, factorw, alpha, dev, theta); }, 0, (Math.PI - dev) / alpha, ref temp, precision); else integrand = new Agt1GnD(factorp, factorw, prefactor, alpha, dev).Integrate(ref temp, precision); // IntegrateFuncExpMFuncDec(delegate(double theta) { return PDFCoreAgt1GnD(factorp, factorw, alpha, dev, theta); }, 0, (Math.PI - dev) / alpha, ref temp, precision); return integrand; }
private static void CDFMethodForPositiveX(double x, double alpha, ref object tempStorage, double precision, out double integFromXZero, out double integFromXInfinity) { const double offs = 0.5; if (alpha < 1) { double factorp, facdiv, dev, logPdfPrefactor; GetAlt1GnParameter(x, alpha, out factorp, out facdiv, out dev, out logPdfPrefactor); Alt1GnI inc = new Alt1GnI(factorp, facdiv, logPdfPrefactor, alpha, dev); if (inc.IsMaximumLeftHandSide()) { integFromXZero = inc.CDFIntegrate(ref tempStorage, precision) / Math.PI; integFromXInfinity = offs - integFromXZero; } else { integFromXInfinity = new Alt1GnD(factorp, facdiv, logPdfPrefactor, alpha, dev).CDFIntegrate(ref tempStorage, precision) / Math.PI; integFromXZero = offs - integFromXInfinity; } } else if (alpha == 1) { if (x <= 1) { integFromXZero = Math.Atan(x) / Math.PI; integFromXInfinity = offs - integFromXZero; } else { integFromXInfinity = Math.Atan(1 / x) / Math.PI; integFromXZero = offs - integFromXInfinity; } } else // if(alpha>1) { double factorp, factorw, dev, logPdfPrefactor; GetAgt1GnParameter(x, alpha, out factorp, out factorw, out dev, out logPdfPrefactor); Agt1GnI inc = new Agt1GnI(factorp, factorw, logPdfPrefactor, alpha, dev); if (inc.IsMaximumLeftHandSide()) { integFromXInfinity = inc.CDFIntegrate(ref tempStorage, precision) / Math.PI; integFromXZero = offs - integFromXInfinity; } else { integFromXZero = new Agt1GnD(factorp, factorw, logPdfPrefactor, alpha, dev).CDFIntegrate(ref tempStorage, precision) / Math.PI; integFromXInfinity = offs - integFromXZero; } } }
public static double PDFIntegration(double x, double alpha, double precision, ref object tempStorage) { if (alpha < 1) { double factorp, facdiv, dev, logPdfPrefactor; GetAlt1GnParameter(x, alpha, out factorp, out facdiv, out dev, out logPdfPrefactor); Alt1GnI intg = new Alt1GnI(factorp, facdiv, logPdfPrefactor, alpha, dev); if (intg.IsMaximumLeftHandSide()) return intg.PDFIntegrate(ref tempStorage, precision); else return new Alt1GnD(factorp, facdiv, logPdfPrefactor, alpha, dev).Integrate(ref tempStorage, precision); } else { double factorp, factorw, dev, logPdfPrefactor; GetAgt1GnParameter(x, alpha, out factorp, out factorw, out dev, out logPdfPrefactor); Agt1GnI intg = new Agt1GnI(factorp, factorw, logPdfPrefactor, alpha, dev); if (intg.IsMaximumLeftHandSide()) return intg.Integrate(ref tempStorage, precision); else return new Agt1GnD(factorp, factorw, logPdfPrefactor, alpha, dev).Integrate(ref tempStorage, precision); } }