# Algorithm for optimizing width length of classes of an ordered list of data points under certain conditions

I have the following problem:

I have an ordered list of $n$ data points jiggling around $0$ with no apparent order. The order this list is in should not be affected by the following procedure. I want to divide this list into 5 classes under the following conditions:

• Average of class no. 2 should be max. positive with variance the lower the better
• Average of class no. 4 should be max. negative with variance the lower the better

The average/variance of the other three classes doesn't matter at the moment.

How can I proceed optimizing the width/cutoff points of the 5 classes (some very crude tests support the belief that this should be possible in general)? Are the perhaps even implementations/tools for such tasks?

Is this problem known under some other name?

-
A version of this question was also posted at stats.stackexchange.com/questions/16556/…. It appears to be an instance of a changepoint problem, but it's not yet posed well enough to admit a definite solution, because it does not describe a single objective function to be optimized. To achieve this, somehow a balance has to be made among two variances, five bin widths, and two vague determinations of "max positive" and "max negative." – whuber Oct 6 '11 at 22:54
@whuber: Do you think that the missing objective function is the problem? So let's take the "signal-to-noise ratio" as the function to optimize, i.e. the ratio of mean to standard deviation (en.wikipedia.org/wiki/Signal-to-noise_ratio). – vonjd Oct 7 '11 at 6:14
S/N ratio appears to have little to do with the original question. How would you propose using that to partition the domain into five intervals? Changepoint procedures will optimize some measure of deviation between the data and the fit (such as the residual variance), adding a penalty for the freedom to change the fitted parameters at four flexibly chosen intermediate cutpoints. If that's what you're looking for, many solutions are described on the stats.SE site. If it's not, it would be helpful to know how your objective differs from this standard one. – whuber Oct 7 '11 at 14:20