Set of Points into Two Groups with Same Average?

82 Views Asked by At

What kind of algorithm using MATLAB or done by hand will allow someone, given a set of data points, to divide them into two groups with as close of an average as possible?

1

There are 1 best solutions below

0
On

Are the subsets of the same size? Of fixed size? Or would for example, finding one single value falling at the overall average be sufficient for one of the two sets*?

*(the other set will be right, since the remaining points will also have the same average)

Are there other characteristics you require of the two subsets?

--

If you want two subsets of equal size, you have the 'partition problem', for which good algorithms exist that can either solve it exactly or approximately

https://en.wikipedia.org/wiki/Partition_problem

--

If you don't care about equal size, then it's effectively a special case of the 'subset sum' problem (one where $s = \frac{1}{2} \sum x_i$),

https://en.wikipedia.org/wiki/Subset_sum_problem

for which algorithms also exist; see for example, the polynomial time algorithm which can give an approximate solution; given here:

https://en.wikipedia.org/wiki/Subset_sum_problem#Polynomial_time_approximate_algorithm