npstat is hosted by Hepforge, IPPP Durham
NPStat  5.10.0
neymanPearsonWindow1D.hh
Go to the documentation of this file.
1 #ifndef NPSTAT_NEYMANPEARSONWINDOW1D_HH_
2 #define NPSTAT_NEYMANPEARSONWINDOW1D_HH_
3 
4 /*!
5 // \file neymanPearsonWindow1D.hh
6 //
7 // \brief Search for a rectangular window in which the likelihood ratio
8 // is above the given threshold
9 //
10 // Author: I. Volobouev
11 //
12 // March 2013
13 */
14 
16 
17 namespace npstat {
18  struct NeymanPearson {
19  enum Status {
20  OK = 0,
21  SUPPORT_BOUNDARY,
22  INDETERMINATE,
23  INVALID
24  };
25  };
26 
27  /**
28  // neymanPearsonWindow1D function assumes that the signal density
29  // is unimodal and that the background density does not vary too
30  // quickly so that the S/B density ratio crosses the threshold
31  // only twice (once on each side of the signal peak).
32  //
33  // Function input arguments are as follows:
34  //
35  // signal -- the signal distribution
36  //
37  // background -- the background distribution
38  //
39  // searchStartCoordinate -- starting point for the search. At this
40  // point the signal/background density ratio
41  // should be above the threshold.
42  //
43  // initialStepSize -- initial step size for the search (in either
44  // direction)
45  //
46  // threshold -- ratio of signal/background densities
47  // to search for. Must be positive.
48  //
49  // On exit, this function fills out the contents of leftBound,
50  // leftBoundStatus, rightBound, and rightBoundStatus. Checking the
51  // status of the window boundary calculation should be considered
52  // essential. The meaning of status values is as follows:
53  //
54  // OK -- Found a good solution. The boundary corresponds
55  // to the given signal/background density ratio.
56  //
57  // SUPPORT_BOUNDARY -- Support boundary of either signal or background
58  // density was reached before solution could be found.
59  //
60  // INDETERMINATE -- The signal/background density ratio became
61  // indeterminate (for example, 0/0) before solution
62  // could be found.
63  //
64  // INVALID -- The function was called with invalid input
65  // values. For example, the density ratio was
66  // below the threshold at the starting point.
67  //
68  // The function returns 0 in case the input arguments pass all sanity
69  // checks and an error code otherwise. For precise meaning of different
70  // error codes see comments to the return statements inside
71  // neymanPearsonWindow1D.cc file.
72  //
73  // Before calling this function, it may be useful to call
74  // "signalToBgMaximum1D". Then the "searchStartCoordinate" could be set
75  // to the position of S/B maximum determined by "signalToBgMaximum1D"
76  // while the threshold must be set to something smaller than the S/B
77  // density ratio at the maximum.
78  */
80  const AbsDistribution1D& background,
81  double searchStartCoordinate,
82  double initialStepSize,
83  double threshold,
84  double* leftBound,
85  NeymanPearson::Status* leftBoundStatus,
86  double* rightBound,
87  NeymanPearson::Status* rightBoundStatus);
88 
89  /**
90  // This function attempts to locate the position of the maximum of
91  // S/B density ratio. It returns 0 in case the input arguments pass
92  // all sanity checks and an error code otherwise.
93  //
94  // Note that, if a point is found for which background density is 0
95  // and signal density is not, this point will be returned as a result.
96  // In this case *maximumSignalToBgRatio will be set to DBL_MAX.
97  */
99  const AbsDistribution1D& background,
100  double searchStartCoordinate,
101  double initialStepSize,
102  double* maximumPosition,
103  double* maximumSignalToBgRatio,
104  NeymanPearson::Status* searchStatus);
105 }
106 
107 #endif // NPSTAT_NEYMANPEARSONWINDOW1D_HH_
Interface definition for 1-d continuous statistical distributions.
Definition: AbsArrayProjector.hh:14
int signalToBgMaximum1D(const AbsDistribution1D &signal, const AbsDistribution1D &background, double searchStartCoordinate, double initialStepSize, double *maximumPosition, double *maximumSignalToBgRatio, NeymanPearson::Status *searchStatus)
int neymanPearsonWindow1D(const AbsDistribution1D &signal, const AbsDistribution1D &background, double searchStartCoordinate, double initialStepSize, double threshold, double *leftBound, NeymanPearson::Status *leftBoundStatus, double *rightBound, NeymanPearson::Status *rightBoundStatus)
Definition: AbsDistribution1D.hh:31
Definition: neymanPearsonWindow1D.hh:18