Detecting Numerical Trends I have a list of numbers that, when plotted on a graph, clearly demonstrate trends such as rising upwards, dropping, repeating etc.. When a human sees the graph, they can easily make out what's happening. What I'm trying to do is achieve the same thing numerically and have the system detect what trends are occurring in the graph. My initial idea is to have a window that shifts along the data, and only the values within this window are used to calculate the trend. A window too small would result in small changes being exaggerated and a window too large would undermine large changes so it might be tricky finding a suitable window size which might make this approach unsuitable.
For example, if I have this set (I've added the square brackets to match the description below, but they're purely illustrative; the data is still only one set):
{[0,1,0,1,0,0],[1,1,1,1,1,1,1],[2,2,4,6,7,8,9,10,9,0],[0,1,1,0,1]}

We can easily see (especially if drawn on a graph) that it starts off relatively stable, then gets stable, starts rising, suddenly drops, then becomes relatively stable again. 
What techniques and topics should I read up on to find ways of having the system detect those types of patterns efficiently? One approach would be to have rules. For example, a counter which increased everytime the number increased and decreased when the number decreased. Then, if the counter passed a high threshold, then the system should return rising. Is this rule-based approach a good way, or are there better approaches? (I prefer efficiency to accuracy, given a trade-off).
 A: A loess smoother is usually the best way to detect 'trends' similar to the ones a human would see.
Here is an example in R, using the data you posted.  The red line is the loess model:
y <- c(0,1,0,1,0,0,1,1,1,1,1,1,1,2,2,4,6,7,8,9,10,9,0,0,1,1,0,1)
x <- 1:length(y)

y.loess <- loess(y ~ x, span=0.25, data.frame(x=x, y=y))
y.predict <- predict(y.loess, data.frame(x=x))

plot(x,y)
lines(x,y.predict,col='red')


A: You can shift a window over your data and fit in each window a straight line. You can plot the resulting slope for each window which eg shows stable regions by a low slope.
http://mathbits.com/mathbits/tisection/statistics1/linefit.htm
A: Use regression  -- look for the "polynomial fitting" slide.
Principal component analysis is useful for analysing multidimensional clusters (there are dramatic examples of representing photographs of faces using only a handful of parameters, or breaking down the political axes exposed by a survey).
Once you have a polynomial you can differentiate it to find the interesting features


*

*maximum slope

*turning points and inflexion points

*trends (in range x=a...x=b the gradient never exceeds amount N)


Regression is nice because does not require an exact fit in the same way that polynomial interpolation does -- so it's more tolerant of errors and noise -- and also you can calculate when the fit is "good enough" according to arbitrary criteria.
You can express a number of machine learning methods (perceptrons, for example) in the language of regression. The only tricky part is inverting what may be a rather large matrix, you'll need a good numerical library to get stable solutions in extreme cases.
A: You could describe your process as a Kalman process, that is, construct a Kalman filter e.g. consisting of current value, first and second derivative and trying to track the position. The Kalman filter would give you a current velocity estimate, which is an estimator for the change.
A: The answer to your question is as follows. Given that you are trying to detect the presence of local time trends this can be seen as an extension of detecting local level shifts, The literature of Intervention Detection  (Not Intervention Modelling which requires a user specification) but rather the search for the points in time where the trend has changed and the magnitude of that change. Now if there are Level shifts and/or ARIMA structure required you will have to integrate all three components in your search.
A: A quick and simple approach might be as follows; decide on an interval, calculate the mean of the values of that interval, compare it to the start and end values of the interval, and categorise the interval as ascending, descending or stable.  If you desire, you can look at the standard devitation of the intervals as well, intervals with high standard deviations might indicate lots of activity and be worthy of closer examination.
Beware of sampling errors as this is not as rigorous an approach as the regression and interpolation suggestions above.
