1 / 8

Algorithm Design and Analysis

L ECTURE 15 Dynamic Programming Segmented Least Squares Discussion of hw problem on spanning subgraphs with short paths. Algorithm Design and Analysis. CSE 565. Adam Smith. Solution to Homework exercise. We discussed the subgraph H output by the procedure in problem 31 (chap. 4)

aimon
Download Presentation

Algorithm Design and Analysis

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. LECTURE 15 • Dynamic Programming • Segmented Least Squares • Discussion of hw problem on spanning subgraphs with short paths Algorithm Design and Analysis CSE 565 Adam Smith A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne

  2. Solution to Homework exercise • We discussed the subgraph H output by the procedure in problem 31 (chap. 4) • Claim 1: H has no cycles of length 4 or less • Claim 2: Any graph with no cycles of length 4 or less has at most n1.5 edges. A. Smith; based on slides by E. Demaine, C. Leiserson, S. Raskhodnikova, K. Wayne

  3. 6.3 Segmented Least Squares

  4. Segmented Least Squares • Least squares. • Foundational problem in statistic and numerical analysis. • Given n points in the plane: (x1, y1), (x2, y2) , . . . , (xn, yn). • Find a line y = ax + b that minimizes the sum of the squared error: • Solution. Calculus  min error is achieved when y x O(n) time

  5. Segmented Least Squares • Segmented least squares. • Points lie roughly on a sequence of several line segments. • Given n points in the plane (x1, y1), (x2, y2) , . . . , (xn, yn) with • x1 < x2 < ... < xn, find a sequence of lines that minimizes f(x). • Q. What's a reasonable choice for f(x) to balance accuracy and parsimony? goodness of fit number of lines y Note: discontinuous functions permitted! x

  6. Segmented Least Squares • Segmented least squares. • Points lie roughly on a sequence of several line segments. • Given n points in the plane (x1, y1), (x2, y2) , . . . , (xn, yn) with • x1 < x2 < ... < xn, find a sequence of lines that minimizes: • the sum of the sums of the squared errors E in each segment • the number of lines L • Tradeoff function: E + c L, for some constant c > 0. y x

  7. Dynamic Programming: Multiway Choice • Notation. • OPT(j) = minimum cost for points p1, pi+1 , . . . , pj. • e(i, j) = minimum sum of squares for points pi, pi+1 , . . . , pj. • To compute OPT(j): • Last segment uses points pi, pi+1 , . . . , pj for some i. • Cost = e(i, j) + c + OPT(i-1).

  8. Segmented Least Squares: Algorithm • Running time. O(n3). • Bottleneck = computing e(i, j) for O(n2) pairs, O(n) per pair using previous formula. INPUT: n, p1,…,pN , c Segmented-Least-Squares() { M[0] = 0 forj = 1 to n fori = 1 to j compute the least square error eij for the segment pi,…, pj forj = 1 to n M[j] = min 1 ij(eij + c + M[i-1]) returnM[n] } can be improved to O(n2) by pre-computingei,j’s

More Related