12double xRooFit::Asymptotics::k(
const IncompatFunc &compatRegions,
double pValue,
double poiVal,
double poiPrimeVal,
13 double sigma,
double low,
double high)
19 double targetTailIntegral = pValue;
23 double prob_in_delta = Phi_m(poiVal, poiPrimeVal, std::numeric_limits<double>::infinity(),
sigma, compatRegions);
32 if (prob_in_delta > 1 - targetTailIntegral) {
36 struct TailIntegralFunction {
37 TailIntegralFunction(
double _poiVal,
double _alt_val,
double _sigma_mu,
double _low,
double _high,
38 IncompatFunc _compatibilityFunction,
double _target)
45 cFunc(_compatibilityFunction)
51 double val = PValue(cFunc,
x, poiVal, alt_val, sigma_mu, low, high);
57 double poiVal, alt_val, sigma_mu, low, high,
target;
62 TailIntegralFunction
f(poiVal, poiPrimeVal,
sigma, low, high, compatRegions, targetTailIntegral);
71 double _prev_pll = _pll;
75 _pll = 2. * (_pll + 1.);
76 }
else if (currVal < -1
e-4) {
86 _pll = std::numeric_limits<double>::quiet_NaN();
94 Warning(
"Asymptotics::k",
"Reached limit pValue=%g pll=%g", pValue, _pll);
97 }
while (std::abs(wf(_pll)) > 1
e-4 && std::abs(wf(_pll)) < std::abs(wf(_prev_pll)) * 0.99);
102double xRooFit::Asymptotics::PValue(
const IncompatFunc &compatRegions,
double k,
double poiVal,
double poi_primeVal,
103 double sigma,
double lowBound,
double upBound)
107 if (compatRegions == IncompatibilityFunction(Uncapped, poiVal)) {
110 return PValue(OneSidedNegative, k, poiVal, poi_primeVal,
sigma, lowBound, upBound);
111 return 1. - (PValue(TwoSided, -k, poiVal, poi_primeVal,
sigma, lowBound, upBound) -
112 PValue(OneSidedNegative, -k, poiVal, poi_primeVal,
sigma, lowBound, upBound));
117 if (compatRegions == IncompatibilityFunction(OneSidedNegative, poiVal) && std::abs(poiVal - poi_primeVal) < 1
e-9)
123 if (lowBound != -std::numeric_limits<double>::infinity() || upBound != std::numeric_limits<double>::infinity()) {
125 }
else if (std::abs(poiVal - poi_primeVal) > 1
e-12) {
134 if (std::abs(poiVal - poi_primeVal) > 1
e-12)
135 Lambda_y = (poiVal - poi_primeVal) /
sigma;
137 if (std::isnan(Lambda_y))
140 double k_low = (lowBound == -std::numeric_limits<double>::infinity()) ? std::numeric_limits<double>::infinity()
141 :
pow((poiVal - lowBound) /
sigma, 2);
142 double k_high = (upBound == std::numeric_limits<double>::infinity()) ? std::numeric_limits<double>::infinity()
143 :
pow((upBound - poiVal) /
sigma, 2);
145 double out = Phi_m(poiVal, poi_primeVal, std::numeric_limits<double>::infinity(),
sigma, compatRegions) - 1;
155 Phi_m(poiVal, poi_primeVal, Lambda_y +
sqrt(k),
sigma, compatRegions);
157 double Lambda_high = (poiVal - upBound) * (poiVal + upBound - 2. * poi_primeVal) / (
sigma *
sigma);
158 double sigma_high = 2. * (upBound - poiVal) /
sigma;
160 Phi_m(poiVal, poi_primeVal, (k - Lambda_high) / sigma_high,
sigma, compatRegions);
165 Phi_m(poiVal, poi_primeVal, Lambda_y -
sqrt(k),
sigma, compatRegions);
167 double Lambda_low = (poiVal - lowBound) * (poiVal + lowBound - 2. * poi_primeVal) / (
sigma *
sigma);
168 double sigma_low = 2. * (poiVal - lowBound) /
sigma;
170 Phi_m(poiVal, poi_primeVal, (Lambda_low - k) / sigma_low,
sigma, compatRegions);
191xRooFit::Asymptotics::Phi_m(
double ,
double mu_prime,
double a,
double sigma,
const IncompatFunc &compatRegions)
200 double lowEdge = std::numeric_limits<double>::quiet_NaN();
201 for (
auto &transition : compatRegions) {
202 if (transition.first >= (
a *
sigma + mu_prime))
204 if (transition.second == 0 && std::isnan(lowEdge)) {
205 lowEdge = transition.first;
206 }
else if (!std::isnan(lowEdge)) {
209 lowEdge = std::numeric_limits<double>::quiet_NaN();
212 if (!std::isnan(lowEdge)) {
219int xRooFit::Asymptotics::CompatFactor(
const IncompatFunc &func,
double mu_hat)
221 if (std::isnan(mu_hat))
224 for (
auto &transition : func) {
225 if (transition.first > mu_hat)
227 out = transition.second;
Int_t gErrorIgnoreLevel
Error handling routines.
void Warning(const char *location, const char *msgfmt,...)
Use this function in warning situations.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
TRObject operator()(const T1 &t1) const
std::vector< std::pair< double, int > > IncompatFunc
Class for finding the root of a one dimensional function using the Brent algorithm.
bool SetFunction(const ROOT::Math::IGenFunction &f, double xlow, double xup) override
Sets the function for the rest of the algorithms.
bool Solve(int maxIter=100, double absTol=1E-8, double relTol=1E-10) override
Returns the X value corresponding to the function value fy for (xmin<x<xmax).
double Root() const override
Returns root value.
Template class to wrap any C++ callable object which takes one argument i.e.
double normal_cdf(double x, double sigma=1, double x0=0)
Cumulative distribution function of the normal (Gaussian) distribution (lower tail).
RVec< PromoteTypes< T0, T1 > > pow(const T0 &x, const RVec< T1 > &v)
double gaussian_cdf(double x, double sigma=1, double x0=0)
Alternative name for same function.
VecExpr< UnaryOp< Sqrt< T >, VecExpr< A, T, D >, T >, T, D > sqrt(const VecExpr< A, T, D > &rhs)
#define BEGIN_XROOFIT_NAMESPACE
#define END_XROOFIT_NAMESPACE