Skip to content

Conversation

tveasey
Copy link
Contributor

@tveasey tveasey commented May 2, 2018

We were previously not using periodic boundary conditions when fitting seasonal components. This is because the value need not be the same at the start and end of the period because of variation in the gradient within the component. A better strategy is to use the predicted value in the next and previous period, since we expect the component to be continuous. As a result, we can enable periodic boundary conditions by default.

This gives a smoother fit to periodic signals. We get lower maximum prediction errors for smooth signals as a result which is reflected in some of the tighter unit test thresholds and also some manual testing I've done. This will affect results for event rate and metric analysis of periodic signals.

@tveasey tveasey force-pushed the enhancement/improve-and-use-periodic-boundary-condition branch from aad9921 to 0a92c58 Compare May 2, 2018 13:58
Copy link
Contributor

@dimitris-athanasiou dimitris-athanasiou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. Left some minor comments.


=== Enhancements

Improve and use periodic boundary condition for seasonal component modeling ({pull}84[#84])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is labelled to go in 6.4 so I think the release note should also be in the 6.4 section. Still getting my head around it though :-)

TDoubleVec f;
TTimeVec times;
TDoubleVec values;
//std::ofstream file;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are useful to have in if there are changes in results. You can uncomment these and look at the modelling we do.

times.push_back(time);
values.push_back(trend);
f.push_back(prediction);
//times.push_back(time);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these be removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As above.

// are adjacent. Note that values need not be the same at the
// start and end of the period because the gradient can vary,
// but we expect them to be continuous.
for (std::size_t j = n - 1; j > 0; --j) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you compared performance after this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only happens very infrequently (when we interpolate which is once per period) so typically once per day, week, etc. As a result these functions are never bottlenecks. For this specific code, n is small and typically this loop exits after the first iteration (only carries on for sparse data). The unit tests didn't noticeably slowdown, so I think this is probably safe from that perspective.

Copy link
Contributor

@dimitris-athanasiou dimitris-athanasiou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tveasey tveasey merged commit 01a6b14 into elastic:master May 3, 2018
tveasey added a commit that referenced this pull request May 4, 2018
#84)

Use the predicted value in the next and previous period when computing endpoint values for
interpolating a seasonal component under periodic boundary conditions and enable periodic
boundary conditions by default.
@tveasey tveasey deleted the enhancement/improve-and-use-periodic-boundary-condition branch March 22, 2019 09:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants