Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
courses:cs211:winter2014:journals:alyssa:chapter_6.3 [2014/03/25 20:48] โ created hardnetta | courses:cs211:winter2014:journals:alyssa:chapter_6.3 [2014/03/25 23:51] (current) โ hardnetta | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Chapter 6.3: Segmented Least Squares ====== | ====== Chapter 6.3: Segmented Least Squares ====== | ||
+ | In previous problems, we've developed recurrence relations based on a binary choice, either //n// belonged to the optimal solution or it didn' | ||
+ | A good example problem is one where we try to find the line(s) of best fit for a set of points. We are given a set of points // | ||
+ | - The number of segments into which we partition //P//, times a fixed, given multiplier //C>0// | ||
+ | - For each segment, the error value of the optimal line through that segment | ||
+ | |||
+ | Our goal is to find a partition of minimum penalty. | ||
+ | |||
+ | ===== Algorithm ===== | ||
+ | In this problem, it is important to remember that the last point //p_n// belongs to a single segment in the optimal partition, and that segment begins at some earlier point //p_i//. Knowing that the last segment is // | ||
+ | |||
+ | Segmented-Least-Squares(n): | ||
+ | * M[0...n] | ||
+ | * M[0]=0 | ||
+ | * For all pairs i < = j: | ||
+ | * compute the error e_i,j for the segment p_i,...,p_j | ||
+ | (end for) | ||
+ | * For j=1, | ||
+ | * compute M[j]=min(e_i, | ||
+ | * return M[n] | ||
+ | |||
+ | Find-Segments(j): | ||
+ | * if j=0 then return nothing | ||
+ | * else: | ||
+ | * find an i that minimizes e_i, | ||
+ | * return the segment {p_i, | ||
+ | |||
+ | Computing all e_i,j values is O(n^3) running time, and the remaining problem runs in O(n^2) time. | ||
+ | |||
+ | I would rate this section a 7. I understood it, but I feel like they could have done a better job setting up the problem. I think the motivation for the problem was explained better in class than in this section. |