CS 100 M Lecture 27 - 27. Design & Model Parameters...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 27. Design & Model Parameters Google PageRank (Cont'd) Optimizing Gear Ratio Distribution A Network .3 2 .7 .6 .2 .2 .3 .1 1 .1 3 .5 Updating the State Vector function w = Update(P,v) n = length(v); w = zeros(n,1); for i=1:n for j=1:n w(i) = w(i) + P(i,j)*v(j); end end The Stationary Vector w = Update(P,v); while max(abs(w-v)) too big v = w; w = Update(P,v) end A Random Walk on the Web Repeat: You are on a webpage. There are m outlinks. Choose one at random. Click on the link. A Connectivity Array 0 1 0 1 0 0 1 0 1 0 1 0 0 1 0 0 0 0 0 1 0 1 0 1 0 0 0 1 1 0 0 0 1 0 1 0 0 0 0 0 0 0 0 1 0 1 0 1 1 1 0 0 1 0 1 0 0 1 0 0 0 0 0 0 G(i,j) is 1 if there is a link on page j to page i G: The Transition Array 0 a 0 a 0 0 a 0 a 0 a 0 0 a 0 0 0 0 0 a 0 a 0 a 0 0 0 b b 0 0 0 b 0 b 0 0 0 0 0 0 0 0 a 0 a 0 a c c 0 0 c 0 c 0 0 1 0 0 0 0 0 0 a = 1/3 b = 1/2 c = 1/4 P: Connectivity Transition [n,n] = size(G); P = zeros(n,n); for j=1:n P(:,j) = G(:,j)/sum(G(:,j)); end Connectivity 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 1 0 1 1 1 0 0 1 0 0 0 0 0 1 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 1 0 1 0 1 1 0 0 Transition 0 .33 .33 0 .33 0 0 0 0 0 0 0 0 0 0 1 0 0 0 .50 .25 0 0 0 .25 0 .25 0 .25 0 0 .50 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 0 .25 0 .25 0 .25 .25 0 0 Stationary Vector 0.5723 0.8206 0.7876 0.2609 0.2064 0.8911 0.2429 0.4100 statVec PageRank 6 2 3 1 8 4 7 5 idx 0.8911 0.8206 0.7876 0.5723 0.4100 0.2609 0.2429 0.2064 sorted 4 2 3 6 8 1 7 5 pR for k=1:8 j = idx(k) % index of kth largest pR(j) = k end 0.5723 0.8206 0.7876 0.2609 0.2064 0.8911 0.2429 0.4100 statVec 0.8911 0.8206 0.7876 0.5723 0.4100 0.2609 0.2429 0.2064 sorted 6 2 3 1 8 4 7 5 idx 4 2 3 6 8 1 7 5 pR PageRank vs InLinkRank Page inLinks outLinks PageRank InLinkRank -----------------------------------------1 2 4 8 5 2 2 1 2 6 3 2 1 1 7 4 5 4 3 1 5 3 3 5 2 6 2 2 6 8 7 3 4 7 3 8 3 3 4 4 A Random Walk on the Web Repeat: You are on a webpage. There are m outlinks. Choose one at random. Click on the link. What if no outlinks? A New Random Walk on the Web Repeat: You are on a webpage. If there are no outlinks Pick a random page and go there else Flip an unfair coin if heads Click on a random outlink and go there else Pick a random page and go there end end The Unfair Coin It comes up heads with probability p = .85. This value "works best." Shakespeare SubWeb (n=4383) Shakespeare Web: Inlink Profile 250 200 Number PRank 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 InRank 24 417 110 14 68 8 37 54 2 261 1 67 118 50 3 150 100 50 0 0 500 1000 1500 2000 2500 Page Index 3000 3500 4000 4500 Shakespeare Web: PageRank Profile 0.012 0.01 PageRankValue 0.008 0.006 0.004 0.002 0 0 500 1000 1500 2000 2500 Page Index 3000 3500 4000 4500 Nat'l Parks SubWeb (n=4757) PRank National Parks Web: Inlink Profile 500 400 Number InRank 1 100 77 386 62 110 37 109 127 32 28 830 169 168 64 300 200 100 0 0 500 1000 1500 2000 2500 3000 Page Index 3500 4000 4500 5000 National Parks Web: PageRank Profile 0.03 0.025 PageRankValue 0.02 0.015 0.01 0.005 0 0 500 1000 1500 2000 2500 3000 Page Index 3500 4000 4500 5000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Basketball SubWeb (n=6049) Basketball Web: Inlink Profile 700 600 500 Number PRank 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 InRank 2 1 20 19 3 61 23 43 91 28 85 358 313 71 68 400 300 200 100 0 0 1000 2000 3000 4000 Page Index 5000 6000 7000 Basketball Web: PageRank Profile 0.025 0.02 PageRankValue 0.015 0.01 0.005 0 0 1000 2000 3000 4000 Page Index 5000 6000 7000 An Optimal Design Problem Gear Ratio Distribution Assume 7 wheel sprockets Assume 3 pedal sprockets 21 = 7 x 3 possible gear ratios It's a Matter of Teeth E.g., 13 teeth E.g., 48 teeth E.g., Gear ratio = 48/13 = 3.692 Goal Choose 3 pedal sprockets and 7 wheel sprockets so that the 21 gear ratios are as evenly distributed across the interval [1,4]. Notation p(i) = #teeth on the i-th pedal sprocket, for i=1:3. w(i) = #teeth on the i-th wheel sprocket, for i=1:7. This is a 10--parameter design problem. Things to Do 1. Define an Objective Function We need to measure the quality of a particular gear ratio distribution 2. Identify constraints. Sprockets are only available in certain sizes etc. Typical activity in Engineering Design The Quality of a Gear Ratio Distribution Ideal: 1 Good: Poor: 4 Average Discrepancy Sort the gear ratios: g(1) < g(2) <... < g(21) Compare g(i) with x(i) where x = linspace(1,4,21). function tau = ObjF(p,w); g = ; for i=1:3 for j=1:7 g = [g p(i)/w(j)]; end end g = sort(g); dif = abs(g linspace(1,4,21)); tau = sum(dif)/21; There Are Other Reasonable Objective Functions g = sort(g); dif = abs(g linspace(1,4,21)); tau = sum(dif)/21; Replace "sum" with "max" Goal Choose p(1:3) and w(1:7) so that objF(p,w) is minimized. This defines the "best bike." Our plan is to check all possible bikes. A 10-fold nested loop problem... A Simplification We may assume that p(3) < p(2) < p(1) and w(7)<w(6)<w(5)<w(4)<w(3<w(2)<w(1) Relabeling the sprockets doesn't change the How Constraints Arise Purchasing says that pedal sprockets only come in six sizes: C1: p(i) is one of 52 48 42 39 32 28. How Constraints Arise Marketing says the best bike must have a maximum gear ratio exactly equal to 4: C2: p(1)/w(7) = 4 This means that p(1) must be a multiple of 4. How Constraints Arise Marketing says the best bike must have a minimum gear ratio exactly equal to 1: C3: p(3)/w(1) = 1 How Constraints Arise Purchasing says that wheel sprockets are available in 31 sizes... C4: w(i) is one of 12, 13,...,42. Choosing Pedal Sprockets Possible values... Front = [52 48 42 39 32 28]; Constraint C1 says that p(1) must be divisible by 4. Also: p(3) < p(2) < p(1). The Possibilities.. 52 52 52 52 52 52 52 48 48 48 48 42 42 42 42 39 32 28 39 32 28 52 52 52 48 48 48 48 39 39 32 42 42 42 39 32 28 28 39 32 28 32 48 48 42 42 42 39 32 39 39 32 28 28 32 28 28 The Loops.. Front = [52 48 42 39 32 28]; for i = 1:3 for j=i+1:6 for k=j+1:6 p(1) = Front(i); p(2) = Front(j); p(3) = Front(k); w(1) and w(7) "for free".. Front = [52 48 42 39 32 28]; for i = 1:3 for j=i+1:6 for k=j+1:6 p(1) = Front(i); p(2) = Front(j); p(3) = Front(k); w(1) = p(3); w(7) = p(1)/4; What About w(2:6) Front = [52 48 42 39 32 28]; for i = 1:3 for j=i+1:6 for k=j+1:6 p(1) = Front(i); p(2) = Front(j); p(3) = Front(k); w(1) = p(3); w(7) = p(1)/4; Select w(2:6) All Possibilities? for a=12:w(1) for b = 12:a-1 for c = 12:b-1 for d = 12:c-1 for e = 12:d-1 w(2) = a; w(3) = b; etc Reduce the Size of The Search Space Build an environment that supports something better than brute force search... Score = 0.038 #Bikes Tested = 23400 Actual: Ideal: 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 w(2): w(3): w(4): w(5): w(6): 13 13 15 21 24 28 42 / 14 20 23 29 22 30 w(7) w(6) w(5) w(4) w(3) w(2) w(1) 42 48 52 p(3) p(2) p(1) ...
View Full Document

This note was uploaded on 02/23/2008 for the course CS 100 taught by Professor Fan/vanloan during the Spring '07 term at Cornell University (Engineering School).

Ask a homework question - tutors are online