Alexandria  2.25.0
SDC-CH common library for the Euclid project
Weights.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022 Euclid Science Ground Segment
3  *
4  * This library is free software; you can redistribute it and/or modify it under
5  * the terms of the GNU Lesser General Public License as published by the Free
6  * Software Foundation; either version 3.0 of the License, or (at your option)
7  * any later version.
8  *
9  * This library is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12  * details.
13  *
14  * You should have received a copy of the GNU Lesser General Public License
15  * along with this library; if not, write to the Free Software Foundation, Inc.,
16  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #ifndef MATHUTILS_WEIGHTS_H
20 #define MATHUTILS_WEIGHTS_H
21 
23 
24 namespace Euclid {
25 namespace MathUtils {
26 
27 struct Likelihood {
28  template <typename Scale, typename Iterator>
29  static auto weight(Scale scale, Iterator ref_begin, Iterator ref_end, Iterator target_begin)
30  -> decltype(ref_begin->getFlux()) {
31  auto chi2 = Chi2Distance::distance(scale, ref_begin, ref_end, target_begin);
32  return std::exp(-0.5f * chi2);
33  }
34 };
35 
36 struct InverseChi2 {
37  template <typename Scale, typename Iterator>
38  static auto weight(Scale scale, Iterator ref_begin, Iterator ref_end, Iterator target_begin)
39  -> decltype(ref_begin->getFlux()) {
40  return 1.f / Chi2Distance::distance(scale, ref_begin, ref_end, target_begin);
41  }
42 };
43 
45  template <typename Scale, typename Iterator>
46  static auto weight(Scale scale, Iterator ref_begin, Iterator ref_end, Iterator target_begin)
47  -> decltype(ref_begin->getFlux()) {
48  return 1.f / EuclideanDistance::distance(scale, ref_begin, ref_end, target_begin);
49  }
50 };
51 
52 } // namespace MathUtils
53 } // namespace Euclid
54 
55 #endif // MATHUTILS_WEIGHTS_H
T exp(T... args)
static auto distance(Scale scale, Iterator ref_begin, Iterator ref_end, Iterator target_begin) -> decltype(ref_begin->getFlux())
Definition: Distances.h:44
static auto distance(Scale scale, Iterator ref_begin, Iterator ref_end, Iterator target_begin) -> decltype(ref_begin->getFlux())
Definition: Distances.h:117
static auto weight(Scale scale, Iterator ref_begin, Iterator ref_end, Iterator target_begin) -> decltype(ref_begin->getFlux())
Definition: Weights.h:38
static auto weight(Scale scale, Iterator ref_begin, Iterator ref_end, Iterator target_begin) -> decltype(ref_begin->getFlux())
Definition: Weights.h:46
static auto weight(Scale scale, Iterator ref_begin, Iterator ref_end, Iterator target_begin) -> decltype(ref_begin->getFlux())
Definition: Weights.h:29