Auxiliary data structure to fit signal strength using likelihood ratio.
More...
#include <JAspera.hh>
|
| void | put (const double s, const double b) |
| | Put signal and background to list of pre-computed N/S values.
|
| |
| void | put (const size_t n, const double s, const double b) |
| | Put signal and background to list of pre-computed N/S values.
|
| |
| double | getLikelihood (const double p) const |
| | Get likelihood for given signal strength.
|
| |
| double | getDerivative (const double p) const |
| | Get derivative of likelihood for given signal strength.
|
| |
| fit_type | operator() (const bool ns=false) const |
| | Fit signal strength.
|
| |
| double | getTestStatisticForUpperLimit (const double ps) const |
| | Get test statistic for given signal strength.
|
| |
| double | getSignal () const |
| | Get total signal strength.
|
| |
| void | setSignal (const double wS) |
| | Set signal strength.
|
| |
| void | addSignal (const double wS) |
| | Add signal strength.
|
| |
|
| static constexpr double | EPSILON = 1.0e-3 |
| | precision determination of signal strength
|
| |
|
| double | ws = 0.0 |
| | total signal strength
|
| |
Auxiliary data structure to fit signal strength using likelihood ratio.
Definition at line 22 of file JAspera.hh.
◆ put() [1/2]
| void JASTRONOMY::JAspera::put |
( |
const double | s, |
|
|
const double | b ) |
|
inline |
Put signal and background to list of pre-computed N/S values.
- Parameters
-
Definition at line 44 of file JAspera.hh.
46 {
47 push_back(b/s);
48
50 }
double ws
total signal strength
◆ put() [2/2]
| void JASTRONOMY::JAspera::put |
( |
const size_t | n, |
|
|
const double | s, |
|
|
const double | b ) |
|
inline |
Put signal and background to list of pre-computed N/S values.
- Parameters
-
| n | data |
| s | signal |
| b | background |
Definition at line 60 of file JAspera.hh.
63 {
64 for (
size_t i = 0; i !=
n; ++i) {
65 push_back(b/s);
66 }
67
69 }
◆ getLikelihood()
| double JASTRONOMY::JAspera::getLikelihood |
( |
const double | p | ) |
const |
|
inline |
Get likelihood for given signal strength.
- Parameters
-
- Returns
- likelihood
Definition at line 78 of file JAspera.hh.
79 {
81
82 for (
const double i : static_cast<const
std::vector<double>&>(*this)) {
84 }
85
87 }
◆ getDerivative()
| double JASTRONOMY::JAspera::getDerivative |
( |
const double | p | ) |
const |
|
inline |
Get derivative of likelihood for given signal strength.
- Parameters
-
- Returns
- derivative of likelihood
Definition at line 96 of file JAspera.hh.
97 {
99
100 for (
const double i : static_cast<const
std::vector<double>&>(*this)) {
102 }
103
105 }
◆ operator()()
| fit_type JASTRONOMY::JAspera::operator() |
( |
const bool | ns = false | ) |
const |
|
inline |
Fit signal strength.
- Parameters
-
| ns | allow for negative signal |
- Returns
- result
Definition at line 114 of file JAspera.hh.
115 {
117
118 if (this->empty()) {
119
120
121
122 return { 0.0, 0.0 };
123
124 } else if (this->size() == 1 ) {
125
126
127
128 const double x = 1.0/
ws - (*this)[0];
129
130 if (x > 0.0 || ns)
132 else
133 return { 0.0, 0.0 };
134 }
135
136 double x1 = 0.0;
137 double x2 = 0.0;
138
140 double f2 = 0.0;
141
142 if (f1 == 0.0) {
143
144 return { 0.0, 0.0 };
145
146 } else if (f1 > 0.0) {
147
148 x1 = 0.0;
149 x2 = (double) this->size() /
ws;
150
152
153 } else if (ns) {
154
155 x2 = 0.0;
156 x1 = -(*this)[0];
157
158 for (
const double i : static_cast<const
std::
vector<double>&>(*this)) {
159 if (-i > x1) {
160 x1 = -i;
161 }
162 }
163
165
166 f2 = f1;
168
169 } else {
170
171 return { 0.0, 0.0 };
172 }
173
174
175
177
178 const double xm = 0.5 * (x1 + x2);
180
181 const double s = sqrt(fm*fm - f1*f2);
182
183 if (s == 0.0) {
184 break;
185 }
186
187 const double xn = xm + (xm - x1) * fm/s;
189
190 if (fn == 0.0) {
192 }
193
194 if (signbit(fn) != signbit(fm)) {
195
196 x1 = xm;
197 f1 = fm;
198 x2 = xn;
199 f2 = fn;
200
201 } else {
202
203 if (signbit(fn)) {
204
205 x2 = xn;
206 f2 = fn;
207
208 } else {
209
210 x1 = xn;
211 f1 = fn;
212 }
213 }
214 }
215
216 const double x = 0.5 * (x1 + x2);
217
219 }
double getLikelihood(const double p) const
Get likelihood for given signal strength.
static constexpr double EPSILON
precision determination of signal strength
double getDerivative(const double p) const
Get derivative of likelihood for given signal strength.
◆ getTestStatisticForUpperLimit()
| double JASTRONOMY::JAspera::getTestStatisticForUpperLimit |
( |
const double | ps | ) |
const |
|
inline |
Get test statistic for given signal strength.
See formula 16 in this reference.
- Parameters
-
- Returns
- test statistic
Definition at line 229 of file JAspera.hh.
230 {
231 const fit_type
result = (*this)(
true);
232
235 else if (
result.signal <= ps)
237 else
238 return 0.0;
239 }
◆ getSignal()
| double JASTRONOMY::JAspera::getSignal |
( |
| ) |
const |
|
inline |
Get total signal strength.
- Returns
- signal strength
Definition at line 247 of file JAspera.hh.
◆ setSignal()
| void JASTRONOMY::JAspera::setSignal |
( |
const double | wS | ) |
|
|
inline |
Set signal strength.
- Parameters
-
Definition at line 258 of file JAspera.hh.
◆ addSignal()
| void JASTRONOMY::JAspera::addSignal |
( |
const double | wS | ) |
|
|
inline |
Add signal strength.
- Parameters
-
Definition at line 269 of file JAspera.hh.
◆ EPSILON
| constexpr double JASTRONOMY::JAspera::EPSILON = 1.0e-3 |
|
staticconstexpr |
precision determination of signal strength
Definition at line 26 of file JAspera.hh.
◆ ws
| double JASTRONOMY::JAspera::ws = 0.0 |
|
protected |
The documentation for this struct was generated from the following file: