lsst.jointcal  master-ga8493ae4fe+4
Chi2.cc
Go to the documentation of this file.
1 /*
2  * LSST Data Management System
3  *
4  * This product includes software developed by the
5  * LSST Project (http://www.lsst.org/).
6  * See the COPYRIGHT file
7  *
8  * This program is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the LSST License Statement and
19  * the GNU General Public License along with this program. If not,
20  * see <https://www.lsstcorp.org/LegalNotices/>.
21  */
22 
23 #include <utility>
24 #include <iostream>
25 
26 #include "lsst/jointcal/Chi2.h"
27 
28 static double sqr(double x) { return x * x; }
29 
30 namespace lsst {
31 namespace jointcal {
32 
33 std::pair<double, double> Chi2List::computeAverageAndSigma() {
34  double sum = 0;
35  double sum2 = 0;
36  for (auto i : *this) {
37  sum += i.chi2;
38  sum2 += sqr(i.chi2);
39  }
40  double average = sum / this->size();
41  double sigma = sqrt(sum2 / this->size() - sqr(average));
42  return std::make_pair(average, sigma);
43 }
44 
45 std::ostream& operator<<(std::ostream& s, Chi2List const& chi2List) {
46  s << "chi2 per star : ";
47  for (auto chi2 : chi2List) {
48  s << *(chi2.star) << " chi2: " << chi2.chi2 << " ; ";
49  }
50  s << std::endl;
51  return s;
52 }
53 
54 } // namespace jointcal
55 } // namespace lsst
friend std::ostream & operator<<(std::ostream &s, Chi2List const &chi2List)
Definition: Chi2.cc:45
Structure to accumulate the chi2 contributions per each star (to help find outliers).
Definition: Chi2.h:84
Class for a simple mapping implementing a generic Gtransfo.
Definition: Associations.h:24
std::pair< double, double > computeAverageAndSigma()
Compute the average and std-deviation of these chisq values.
Definition: Chi2.cc:33