====== Differences ====== This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
gibson:teaching:fall-2012:math445:lab6 [2012/10/15 11:48] gibson |
gibson:teaching:fall-2012:math445:lab6 [2012/10/17 12:14] (current) gibson |
||
---|---|---|---|
Line 30: | Line 30: | ||
**(a)** Go to the website [[http://www.mathworks.com/moler/chapters.html|Numerical Computing with Matlab]] | **(a)** Go to the website [[http://www.mathworks.com/moler/chapters.html|Numerical Computing with Matlab]] | ||
- | by Clive Moler and download the “surfer.m” program. Set ''N =100'' and run the command | + | by Clive Moler and download the “surfer.m” program. Set ''N=100'' and run the command |
- | ''[U,G] = surfer('http://www.unh.edu',N)''. This might take a few minutes. | + | ''[U,G] = surfer('http://www.unh.edu',N);''. This might take a few minutes. |
**(b)** After some time a vector ''U'' of websites will be generated and a matrix ''G'' of links will | **(b)** After some time a vector ''U'' of websites will be generated and a matrix ''G'' of links will | ||
- | be generated. Look at the matrix ''G''. All the entries should be 1 if they are not 0. We need to | + | be generated. All the entries of ''G'' should be either 0 or 1. But ''G'' will have 100^2 == 10,000 entries, |
- | scale these to probabilities as done in class. Namely, every column of ''G'' should sum to 1. Write | + | so you can't check this by eye. Write a short piece of Matlab code that double-checks that all entries of |
- | code to scale each column so the sum is 1. I recommend you do not modify the original G but | + | ''G'' are either 0 or 1. |
- | create a new matrix of scaled links H. | + | |
- | **(c)** You will probably run into an error in part 2, namely a webpage might contain no links or only | + | **%%(c)%%** Now generate an ''H'' matrix as described in problem 1. You will probably run into an error in |
- | links outside the set of 100 we are working with. In that case we will just assume that the person | + | part 2, namely a webpage might contain no links or only links outside the set of pages we are working with. |
- | randomly selects a new website with some small probability. Revise your calculation of ''H'' so | + | In that case we will just assume that the person randomly selects a new website among all the ''N'' pages |
- | that if a column of ''G'' sums to zero, then each of the entries in the same column of ''H'' is ''1/N''. | + | in our set. Revise your calculation of ''H'' so that if a column of ''G'' sums to zero, then each of the |
+ | entries in the same column of ''H'' is ''1/N''. | ||
**(d)** Suppose that instead of always clicking on a random link within a page, a web surfer sometimes | **(d)** Suppose that instead of always clicking on a random link within a page, a web surfer sometimes | ||
Line 49: | Line 49: | ||
model this behavior with a new transition matrix ''T'' given by | model this behavior with a new transition matrix ''T'' given by | ||
- | ''T = (1-alpha) H + alpha **1**/N'' | + | ''T = (1-alpha) H + alpha **1**/N;'' |
where **1** is a matrix of ones. Rumour has it that Google uses alpha = 0.15, so use that value | where **1** is a matrix of ones. Rumour has it that Google uses alpha = 0.15, so use that value | ||
Line 90: | Line 90: | ||
respect to these two numbers? If you change alpha to 0.1 or 0.05, do the top 10 pages change? | respect to these two numbers? If you change alpha to 0.1 or 0.05, do the top 10 pages change? | ||
How about if you change ''m'' to 10^4? | How about if you change ''m'' to 10^4? | ||
- | |||