12Double_t 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)
39 : poiVal(_poiVal), alt_val(_alt_val), sigma_mu(_sigma_mu), low(_low), high(_high),
target(_target),
40 cFunc(_compatibilityFunction)
46 double val = PValue(cFunc,
x, poiVal, alt_val, sigma_mu, low, high);
52 double poiVal, alt_val, sigma_mu, low, high,
target;
57 TailIntegralFunction
f(poiVal, poiPrimeVal,
sigma, low, high, compatRegions, targetTailIntegral);
66 double _prev_pll = _pll;
70 _pll = 2. * (_pll + 1.);
71 else if (currVal < -1
e-4)
80 _pll = std::numeric_limits<double>::quiet_NaN();
88 Warning(
"Asymptotics::k",
"Reached limit pValue=%g pll=%g", pValue, _pll);
91 }
while (std::abs(wf(_pll)) > 1
e-4 && std::abs(wf(_pll)) < std::abs(wf(_prev_pll)) * 0.99);
96Double_t xRooFit::Asymptotics::PValue(
const IncompatFunc &compatRegions,
double k,
double poiVal,
double poi_primeVal,
97 double sigma,
double lowBound,
double upBound)
101 if (compatRegions == IncompatibilityFunction(Uncapped, poiVal)) {
104 return PValue(OneSidedNegative, k, poiVal, poi_primeVal,
sigma, lowBound, upBound);
105 return 1. - (PValue(TwoSided, -k, poiVal, poi_primeVal,
sigma, lowBound, upBound) -
106 PValue(OneSidedNegative, -k, poiVal, poi_primeVal,
sigma, lowBound, upBound));
111 if (compatRegions == IncompatibilityFunction(OneSidedNegative, poiVal) && std::abs(poiVal - poi_primeVal) < 1
e-9)
117 if (lowBound != -std::numeric_limits<double>::infinity() || upBound != std::numeric_limits<double>::infinity()) {
119 }
else if (std::abs(poiVal - poi_primeVal) > 1
e-12) {
128 if (std::abs(poiVal - poi_primeVal) > 1
e-12)
129 Lambda_y = (poiVal - poi_primeVal) /
sigma;
131 if (std::isnan(Lambda_y))
134 Double_t k_low = (lowBound == -std::numeric_limits<double>::infinity()) ? std::numeric_limits<double>::infinity()
135 :
pow((poiVal - lowBound) /
sigma, 2);
136 Double_t k_high = (upBound == std::numeric_limits<double>::infinity()) ? std::numeric_limits<double>::infinity()
137 :
pow((upBound - poiVal) /
sigma, 2);
139 double out = Phi_m(poiVal, poi_primeVal, std::numeric_limits<double>::infinity(),
sigma, compatRegions) - 1;
149 Phi_m(poiVal, poi_primeVal, Lambda_y +
sqrt(k),
sigma, compatRegions);
151 double Lambda_high = (poiVal - upBound) * (poiVal + upBound - 2. * poi_primeVal) / (
sigma *
sigma);
152 double sigma_high = 2. * (upBound - poiVal) /
sigma;
154 Phi_m(poiVal, poi_primeVal, (k - Lambda_high) / sigma_high,
sigma, compatRegions);
159 Phi_m(poiVal, poi_primeVal, Lambda_y -
sqrt(k),
sigma, compatRegions);
161 double Lambda_low = (poiVal - lowBound) * (poiVal + lowBound - 2. * poi_primeVal) / (
sigma *
sigma);
162 double sigma_low = 2. * (poiVal - lowBound) /
sigma;
164 Phi_m(poiVal, poi_primeVal, (Lambda_low - k) / sigma_low,
sigma, compatRegions);
185xRooFit::Asymptotics::Phi_m(
double ,
double mu_prime,
double a,
double sigma,
const IncompatFunc &compatRegions)
194 double lowEdge = std::numeric_limits<double>::quiet_NaN();
195 for (
auto &transition : compatRegions) {
196 if (transition.first >= (
a *
sigma + mu_prime))
198 if (transition.second == 0 && std::isnan(lowEdge))
199 lowEdge = transition.first;
200 else if (!std::isnan(lowEdge)) {
203 lowEdge = std::numeric_limits<double>::quiet_NaN();
206 if (!std::isnan(lowEdge)) {
213int xRooFit::Asymptotics::CompatFactor(
const IncompatFunc &func,
double mu_hat)
215 if (std::isnan(mu_hat))
218 for (
auto &transition : func) {
219 if (transition.first > mu_hat)
221 out = transition.second;
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
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.
std::vector< std::pair< double, int > > IncompatFunc
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