Given n points in a 3D space. Each point can be represented as (x_i, y_i, z_i).
Now we can split the x-axis into m continuous intervals and so as the y-axis, and we get m*n grids.
For each grid, we define the error as sum(z_i - z^{bar})^2, where z^{bar} is the average value of z in each grid.
The object is to minimize the total error of all the grids, and further more, plus the number of grids.
So how to solve it with dynamic programming?