From 07960418bc16f87a3afe30ef1c4b7e2a0e3d4e67 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Sat, 21 Oct 2017 17:27:37 +0200 Subject: [PATCH] Use CSTAT and CHI2 instead of POISSON and GAUSSIAN for statistic (#2237) --- ChangeLog | 1 + NEWS | 4 ++++ doc/source/admin/release_history/1.5.rst | 2 ++ include/GObservation.hpp | 2 +- inst/cta/src/GCTAOnOffObservation.cpp | 3 --- src/obs/GObservation.cpp | 17 +++++++++-------- 6 files changed, 17 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index a05de31..815768c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4,6 +4,7 @@ ========================= CTA observations handle "statistic" attribute in XML file (#2238) + Use CSTAT and CHI2 instead of POISSON and GAUSSIAN for statistic (#2237) Changed GObservation::statistics() to statistic() (#2238) Prevent negative response values for COMPTEL IRF (#2234) Add GCTAOnOffObservation PHA, ARF and RMF constructor (#2231) diff --git a/NEWS b/NEWS index 799e6d7..cb85edb 100644 --- a/NEWS +++ b/NEWS @@ -141,6 +141,10 @@ None 10. Observation module ---------------------- +The statistic were renamed. POISSON is now called CSTAT and GAUSSIAN is called +CHI2. The code still accepts POISSON and GAUSSIAN, but it is recommended to use +CSTAT and CHI2 instead (#2237). + The GResponse::eval_prob() method was speed up by avoiding computation for the case that the spatial response is non-positive. In that case the spectral response is no longer evaluated. diff --git a/doc/source/admin/release_history/1.5.rst b/doc/source/admin/release_history/1.5.rst index 2a4e9e2..6e9bf81 100644 --- a/doc/source/admin/release_history/1.5.rst +++ b/doc/source/admin/release_history/1.5.rst @@ -82,4 +82,6 @@ Clean up * [`2238 `_] - Changed ``GObservation::statistics()`` to ``GObservation::statistic()`` +* [`2237 `_] - + Use ``CSTAT`` and ``CHI2`` instead of ``POISSON`` and ``GAUSSIAN`` for statistic diff --git a/include/GObservation.hpp b/include/GObservation.hpp index 93e9214..a6f36a6 100644 --- a/include/GObservation.hpp +++ b/include/GObservation.hpp @@ -209,7 +209,7 @@ protected: // Protected data area std::string m_name; //!< Observation name std::string m_id; //!< Observation identifier - std::string m_statistic; //!< Optimizer statistic (default=Poisson) + std::string m_statistic; //!< Optimizer statistic GEvents* m_events; //!< Pointer to event container }; diff --git a/inst/cta/src/GCTAOnOffObservation.cpp b/inst/cta/src/GCTAOnOffObservation.cpp index 0a8bfe8..c50172e 100644 --- a/inst/cta/src/GCTAOnOffObservation.cpp +++ b/inst/cta/src/GCTAOnOffObservation.cpp @@ -797,9 +797,6 @@ void GCTAOnOffObservation::init_members(void) m_rmf.clear(); m_logetrue.clear(); - // Overwrite base class statistic - m_statistic = "Poisson"; - // Return return; } diff --git a/src/obs/GObservation.cpp b/src/obs/GObservation.cpp index a3e681c..cd73389 100644 --- a/src/obs/GObservation.cpp +++ b/src/obs/GObservation.cpp @@ -188,7 +188,7 @@ double GObservation::likelihood(const GModels& models, if (dynamic_cast(events()) != NULL) { // Poisson statistic - if (statistic == "POISSON") { + if ((statistic == "POISSON") || (statistic == "CSTAT")) { // Update the log-likelihood value = likelihood_poisson_unbinned(models, @@ -201,7 +201,8 @@ double GObservation::likelihood(const GModels& models, // ... otherwise throw an exception else { std::string msg = "Invalid statistic \""+statistic+"\". Unbinned " - "optimization requires \"POISSON\" statistic."; + "optimization requires \"POISSON\" or \"CSTAT\" " + "statistic."; throw GException::invalid_value(G_LIKELIHOOD, msg); } @@ -211,7 +212,7 @@ double GObservation::likelihood(const GModels& models, else { // Poisson statistic - if (statistic == "POISSON") { + if ((statistic == "POISSON") || (statistic == "CSTAT")) { value = likelihood_poisson_binned(models, gradient, curvature, @@ -219,7 +220,7 @@ double GObservation::likelihood(const GModels& models, } // ... or Gaussian statistic - else if (statistic == "GAUSSIAN") { + else if ((statistic == "GAUSSIAN") || (statistic == "CHI2")) { value = likelihood_gaussian_binned(models, gradient, curvature, @@ -228,9 +229,9 @@ double GObservation::likelihood(const GModels& models, // ... or unsupported else { - std::string msg = "Invalid statistic \""+statistic+"\". Unbinned " - "optimization requires \"POISSON\" or " - "\"GAUSSIAN\" statistic."; + std::string msg = "Invalid statistic \""+statistic+"\". Binned " + "optimization requires \"POISSON\", \"CSTAT\", " + "\"GAUSSIAN\" or \"CHI2\" statistic."; throw GException::invalid_value(G_LIKELIHOOD, msg); } @@ -835,7 +836,7 @@ void GObservation::init_members(void) // Initialise members m_name.clear(); m_id.clear(); - m_statistic = "Poisson"; + m_statistic = "cstat"; m_events = NULL; // Return -- libgit2 0.21.4