Checking that values are piecewise uniform I have a set of values and I wish to check if they are piecewise uniform. I hope I'm using the correct terms, but I'll explain what I mean. 
Consider the following values - 100,105,100,103,98. 
We can "see" they are close to each other. We can define this uniformity by normalizing the Standard deviation.
Now let's look at the following values - 100,105,100,103,98,198,200,203,205,100,105,100,103,98
Standard deviation will not work here, but it's clearly uniform in each segment. To check the uniformity here we can check how many of the sample deviate by no more than d% from their predecessor. This seems to work but (and here's the question) - is there a better approach? I don't even know how to call this test to try and search for articles.
This doesn't handle outliers very well. I can use a moving average or a moving median, and again - is there something better?
Thanks.
 A: The simplest thing to do is to run outlier checks on differences. 
For instance, take a look at the plot of X and the first differences below. You can see that the points 5 and 9 will be detected by outlier diagnostics. You could fit a simple linear model $\Delta y_i=c+e_i$, where $c$ is a constant, and get the diagnostics such as Cook's distance, which should detect the outliers.

A: In changepoints if you want to assume a distribution for each segment then you can test if there is a changepoint (or multiple changepoints) using a likelihood ratio test.
So in your example you would fit a Uniform distribution to the pre-change and post-change observations separately, calculate the likelihood and repeat this for each possible changepoint location.  Then the most likely changepoint location is the one with the highest likelihood.  You then test this by comparing the ratio between the null (no change) likelihood and alternative (one change at the maximized location) likelihood to a threshold.
The above is the general likelihood setup.  I've not come across this done for a Uniform distribution before, but give it a google and see what you find.
