{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

FinRevSol - 100M Lecture-Based Review Questions for the...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
100M: Lecture-Based Review Questions for the Final Exam (Solutions) 1. (Lecture 27) Modify the following function so that it is more e cient. function w = Update(P,v) % P is an n-by-n array of transition probabilities WITH THE PROPERTY % THAT P(i,j) IS ZERO IF |i-j|>1 % v is an n-by-1 state vector % w is the update of v n = length(v); w = zeros(n,1); for i=1:n % Compute the i-th component of the new state vector.. if i==1 w(1) = P(1,1)*v(1) + P(1,2)*v(2); elseif i==n w(n) = P(n,n-1)*v(n-1) + P(n,n)*v(n); else w(i) = P(i,i-1)*v(i-1) + P(i,i)*v(i) + P(i,i+1)*v(i); end end 2. (Lecture 27) Suppose G is a given n-by-n connectivity array with no columns that are zero. Using the function function [pR,pRValues] = PageRank0(G) % G is an n-by-n connectivity array with no columns that are all zeros. % pR is an n-by-1 array with the property that pR(j) is the page % rank of page j. Write a script that prints the indices of all the webpages that have a link pointing to the page with the highest page rank. [pR,pRValues] = PageRank0(G); % Index of the page that has page rank 1: i=pR(1); for j=1:n % G(i,j) = 1 if there is a link from page j to page i if G(i,j)==1 disp(j) end end 3. (Lecture 26) Refer to the following function: function C = CensusData % Packages the data that is in the files Names.dat, Pop.dat, and Rep.dat % to facilitate the analysis of US census data and how it is used to % determine the number of congressional seats for each state. 1
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
% There are 22 census dates: 1790, 1800,..., 2000. % % C is a length 22 structure array with these fields: % year The year of the census. (1790, 1800,...,2000). % states k-by-16 char array that names existing states during the census. % pop k-by-1 real array that specifies the state populations.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}