What's the best way to check if a sequence of numbers has an increasing or decreasing trend?
I know that I could pick the first and last value of the sequence, and check their difference, but I'd like a somewhat more robust check. This means that I want to be able to tolerate a minority of increasing values within a mostly decreasing sequence, and viceversa.
More specifically, the numbers are stored as
vector<int> mySequence;
A few more details about the number sequences that I am dealing with:
I would accumulate the number of increases vs number of decreases, which should give you an idea of whether there's an overall trend to increase or decrease.
You probably could look into trend estimation and some type of regression like linear regression.
It depends of course on the specific application of yours, but in general it sounds like a fitting problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With