Finding groups with minimum mean deviation

43 Views Asked by At

Is there any algorithm that groups consecutive elements in an array that gives the minimum mean deviation. For example we are given an array a=[1,2,3,4,8,2,3,5]

There can be many "consecutive" groups or clusters like (1+2),(3+4+8),(2+3+5) whose mean comes out to be (3+15+10)/3=28/3=9(approx). and deviation comes out to be (9-3)^2+(9-15)^2+(10-15)^2/3.

How to find which grouping has the minimum mean deviation?