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.