From 05098b09c3bb2c3c001a9722f9b63d88df2c9430 Mon Sep 17 00:00:00 2001 From: Tom Veasey Date: Fri, 17 Jul 2020 08:47:42 +0100 Subject: [PATCH] [ML] Testing for no change should not use the change trend model Change #1391 introduced a subtle error: when computing the likelihood of no change we should use a reference to the current time series trend model, not the copy of the model which assumes a change is occurring. --- lib/maths/CTimeSeriesChangeDetector.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/maths/CTimeSeriesChangeDetector.cc b/lib/maths/CTimeSeriesChangeDetector.cc index 797865af5b..49cc0862a5 100644 --- a/lib/maths/CTimeSeriesChangeDetector.cc +++ b/lib/maths/CTimeSeriesChangeDetector.cc @@ -98,13 +98,13 @@ CUnivariateTimeSeriesChangeDetector::CUnivariateTimeSeriesChangeDetector( : m_MinimumTimeToDetect{minimumTimeToDetect}, m_MaximumTimeToDetect{maximumTimeToDetect}, m_MinimumDeltaBicToDetect{minimumDeltaBicToDetect}, m_SampleCount{0}, m_DecisionFunction{0.0}, m_TrendModel{trendModel->clone()} { + m_ChangeModels.push_back( + std::make_unique(trendModel, residualModel)); this->initChangeModels(residualModel); } void CUnivariateTimeSeriesChangeDetector::initChangeModels(TPriorPtr residualModel) { - m_ChangeModels.clear(); - m_ChangeModels.push_back( - std::make_unique(m_TrendModel, residualModel)); + m_ChangeModels.resize(1); m_ChangeModels.push_back( std::make_unique(m_TrendModel, residualModel)); if (m_TrendModel->seasonalComponents().size() > 0) {