Commit 783c7ed1 authored by Jim Hefferon's avatar Jim Hefferon

another page rank exercise

parent 4047c798
......@@ -137,6 +137,11 @@
Web Search Engine},
\url{http://infolab.stanford.edu/pub/papers/google.pdf},
retrieved Feb.~2012.
\bibitem[Bryan \& Leise]{BryanLeise}
Kurt Bryan, Tanya Leise,
\emph{The \$25,000,000,000 Eigenvector: the Linear Algebra Behind Google},
SIAM Review,
Vol.\ 48, no.\ 3 (2006), p.\ 569-81.
\bibitem[Casey]{Casey}
John Casey,
\emph{The Elements of Euclid, Books~I to~VI and~XI},
......
This diff is collapsed.
......@@ -29479,6 +29479,66 @@ ans = 0.017398
=\alpha\cdot 1+(1-\alpha)\cdot 1$,
which is one.
\end{ans}
\begin{ans}{2}
We have this.
\begin{equation*}
H=\begin{mat}
0 &0 &1 &1/2 \\
1/3 &0 &0 &0 \\
1/3 &1/2 &0 &1/2 \\
1/3 &1/2 &0 &0
\end{mat}
\end{equation*}
\begin{exparts}
\item This \textit{Sage} session gives the answer.
\begin{lstlisting}
sage: H=matrix(QQ,[[0,0,1,1/2], [1/3,0,0,0], [1/3,1/2,0,1/2], [1/3,1/2,0,0]])
sage: S=matrix(QQ,[[1/4,1/4,1/4,1/4], [1/4,1/4,1/4,1/4], [1/4,1/4,1/4,1/4], [1/4,1/4,1/4,1/4]])
sage: I=matrix(QQ,[[1,0,0,0], [0,1,0,0], [0,0,1,0], [0,0,0,1]])
sage: alpha=0.85
sage: G=alpha*H+(1-alpha)*S
sage: N=G-I
sage: 1200*N
[-1155.00000000000 45.0000000000000 1065.00000000000 555.000000000000]
[ 385.000000000000 -1155.00000000000 45.0000000000000 45.0000000000000]
[ 385.000000000000 555.000000000000 -1155.00000000000 555.000000000000]
[ 385.000000000000 555.000000000000 45.0000000000000 -1155.00000000000]
sage: M=matrix(QQ,[[-1155,45,1065,555], [385,-1155,45,45], [385,555,-1155,555], [385,555,45,-1155]])
sage: M.echelon_form()
[ 1 0 0 -106613/58520]
[ 0 1 0 -40/57]
[ 0 0 1 -57/40]
[ 0 0 0 0]
sage: v=vector([106613/58520,40/57,57/40,1])
sage: (v/v.norm()).n()
(0.696483066294572, 0.268280959381099, 0.544778023143244, 0.382300367118066)
\end{lstlisting}
\item Continue the \textit{Sage} to get this.
\begin{lstlisting}
sage: alpha=0.95
sage: G=alpha*H+(1-alpha)*S
sage: N=G-I
sage: 1200*N
[-1185.00000000000 15.0000000000000 1155.00000000000 585.000000000000]
[ 395.000000000000 -1185.00000000000 15.0000000000000 15.0000000000000]
[ 395.000000000000 585.000000000000 -1185.00000000000 585.000000000000]
[ 395.000000000000 585.000000000000 15.0000000000000 -1185.00000000000]
sage: M=matrix(QQ,[[-1185,15,1155,585], [395,-1185,15,15], [395,585,-1185,585], [395,585,15,-1185]])
sage: M.echelon_form()
[ 1 0 0 -361677/186440]
[ 0 1 0 -40/59]
[ 0 0 1 -59/40]
[ 0 0 0 0]
sage: v=vector([361677/186440,40/59,59/40,1])
sage: (v/v.norm()).n()
(0.713196892748114, 0.249250262646952, 0.542275102671275, 0.367644137404254)
\end{lstlisting}
\item Page $p_3$ is important, but it passes its importance on to
only one page, $p_1$.
So that page receives a large boost.
\end{exparts}
\end{ans}
\subsection{Topic: Linear Recurrences}
\begin{ans}{1}
......@@ -373,22 +373,22 @@ beginfig(9); % m
%numeric u; %scaling factor
%numeric v; %vertical scaling factor
%numeric w; %horizontal scaling factor
numeric circlescale; circlescale=20pt;
numeric circlescale; circlescale=19pt;
path node; node=fullcircle scaled circlescale;
path n[]; % node paths
pickup pencircle scaled line_width_light;
z1=(0w,6v);
n1=node shifted z1;
draw n1; label(btex $p_1$ etex,z1);
draw n1; label(btex \small $p_1$ etex,z1);
z2=(9w,y1);
n2=node shifted z2;
draw n2; label(btex $p_2$ etex,z2);
draw n2; label(btex \small $p_2$ etex,z2);
z3=(x2,0v);
n3=node shifted z3;
draw n3; label(btex $p_3$ etex,z3);
draw n3; label(btex \small $p_3$ etex,z3);
z4=(x1,y3);
n4=node shifted z4;
draw n4; label(btex $p_4$ etex,z4);
draw n4; label(btex \small $p_4$ etex,z4);
path p[], q[];
pair times[]; % intersection times
% arrow from p1 to p2
......@@ -414,6 +414,63 @@ beginfig(9); % m
endfig;
% Exercise from KURT BRYAN AND TANYA LEISE
%
beginfig(10); % m
%numeric u; %scaling factor
%numeric v; %vertical scaling factor
%numeric w; %horizontal scaling factor
numeric circlescale; circlescale=19pt;
path node; node=fullcircle scaled circlescale;
path n[]; % node paths
pickup pencircle scaled line_width_light;
z1=(0w,6v);
n1=node shifted z1;
draw n1; label(btex \small $p_1$ etex,z1);
z2=(9w,y1);
n2=node shifted z2;
draw n2; label(btex \small $p_2$ etex,z2);
z3=(x2,0v);
n3=node shifted z3;
draw n3; label(btex \small $p_3$ etex,z3);
z4=(x1,y3);
n4=node shifted z4;
draw n4; label(btex \small $p_4$ etex,z4);
path p[], q[];
pair times[]; % intersection times
% arrow from p1 to p2
p12=z1--z2;
times121=p12 intersectiontimes n1;
times122=p12 intersectiontimes n2;
drawarrow subpath(xpart(times121)+.05,xpart(times122)-.05) of p12;
% arrow from p1 to p3
p13=z1--z3;
times131=p13 intersectiontimes n1;
times133=p13 intersectiontimes n3;
drawdblarrow subpath(xpart(times131)+.05,xpart(times133)-.05) of p13;
% arrow from p1 to p4
p14=z1--z4;
times141=p14 intersectiontimes n1;
times144=p14 intersectiontimes n4;
drawdblarrow subpath(xpart(times141)+.05,xpart(times144)-.05) of p14;
% arrow from p2 to p3
p23=z2--z3;
times232=p23 intersectiontimes n2;
times233=p23 intersectiontimes n3;
drawarrow subpath(xpart(times232)+.05,xpart(times233)-.05) of p23;
% arrow from p2 to p4
p24=z2--z4;
times242=p24 intersectiontimes n2;
times244=p24 intersectiontimes n4;
drawarrow subpath(xpart(times242)+.05,xpart(times244)-.05) of p24;
% arrow from p4 to p5
p43=z4--z3;
times433=p43 intersectiontimes n4;
times434=p43 intersectiontimes n3;
drawarrow subpath(xpart(times433)+.05,xpart(times434)-.05) of p43;
endfig;
end
\ No newline at end of file
No preview for this file type
......@@ -35,7 +35,7 @@ Today's statistics would be quite different, both because of
inflation and because of technical changes in the industries.)
\begin{center}
\begin{tabular}{r|rrrr}
\multicolumn{1}{c|}{\ } %put the | in the right place
\multicolumn{1}{c}{\ } %put the | in the right place
&\multicolumn{1}{r}{\begin{tabular}[b]{@{}c@{}}
\textit{used by} \\[-.5ex] \textit{steel}
\end{tabular}}
......@@ -46,7 +46,7 @@ inflation and because of technical changes in the industries.)
\textit{used by} \\[-.5ex] \textit{others}
\end{tabular}}
&\textit{total} \\
\hline
\cline{2-5}
\begin{tabular}{r} \textit{value of} \\[-.5ex] \textit{steel} \end{tabular}
&$5\,395$ &$2\,664$ & &$25\,448$ \\
\begin{tabular}{r} \textit{value of} \\[-.5ex] \textit{auto} \end{tabular}
......
......@@ -160,6 +160,7 @@ $\alpha$'s.
% Numbers computed as:
% sage: H=matrix(QQ,[[0,0,1/3,1/4], [1,0,1/3,1/4], [0,1,0,1/4], [0,0,1/3,1/4]])
% sage: S=matrix(QQ,[[1/4,1/4,1/4,1/4], [1/4,1/4,1/4,1/4], [1/4,1/4,1/4,1/4], [1/4,1/4,1/4,1/4]])
% sage: I=matrix(QQ,[[1,0,0,0], [0,1,0,0], [0,0,1,0], [0,0,0,1]])
% sage: alpha=0.95
% sage: G=alpha*H+(1-alpha)*S
% sage: N=G-I
......@@ -203,6 +204,78 @@ Two additional excellent expositions are
=\alpha\cdot 1+(1-\alpha)\cdot 1$,
which is one.
\end{answer}
\item \cite{BryanLeise}
Give the importance ranking for this web of pages.
\begin{center}
\includegraphics{ch5.10}
\end{center}
\begin{exparts}
\item Use $\alpha=0.85$.
\item Use $\alpha=0.95$.
\item Observe that while $p_3$ is linked-to from all other pages,
and therefore seems important, it is not the highest ranked page.
What is the highest ranked page?
Explain.
\end{exparts}
\begin{answer}
We have this.
\begin{equation*}
H=\begin{mat}
0 &0 &1 &1/2 \\
1/3 &0 &0 &0 \\
1/3 &1/2 &0 &1/2 \\
1/3 &1/2 &0 &0
\end{mat}
\end{equation*}
\begin{exparts}
\item This \textit{Sage} session gives the answer.
\begin{lstlisting}
sage: H=matrix(QQ,[[0,0,1,1/2], [1/3,0,0,0], [1/3,1/2,0,1/2], [1/3,1/2,0,0]])
sage: S=matrix(QQ,[[1/4,1/4,1/4,1/4], [1/4,1/4,1/4,1/4], [1/4,1/4,1/4,1/4], [1/4,1/4,1/4,1/4]])
sage: I=matrix(QQ,[[1,0,0,0], [0,1,0,0], [0,0,1,0], [0,0,0,1]])
sage: alpha=0.85
sage: G=alpha*H+(1-alpha)*S
sage: N=G-I
sage: 1200*N
[-1155.00000000000 45.0000000000000 1065.00000000000 555.000000000000]
[ 385.000000000000 -1155.00000000000 45.0000000000000 45.0000000000000]
[ 385.000000000000 555.000000000000 -1155.00000000000 555.000000000000]
[ 385.000000000000 555.000000000000 45.0000000000000 -1155.00000000000]
sage: M=matrix(QQ,[[-1155,45,1065,555], [385,-1155,45,45], [385,555,-1155,555], [385,555,45,-1155]])
sage: M.echelon_form()
[ 1 0 0 -106613/58520]
[ 0 1 0 -40/57]
[ 0 0 1 -57/40]
[ 0 0 0 0]
sage: v=vector([106613/58520,40/57,57/40,1])
sage: (v/v.norm()).n()
(0.696483066294572, 0.268280959381099, 0.544778023143244, 0.382300367118066)
\end{lstlisting}
\item Continue the \textit{Sage} to get this.
\begin{lstlisting}
sage: alpha=0.95
sage: G=alpha*H+(1-alpha)*S
sage: N=G-I
sage: 1200*N
[-1185.00000000000 15.0000000000000 1155.00000000000 585.000000000000]
[ 395.000000000000 -1185.00000000000 15.0000000000000 15.0000000000000]
[ 395.000000000000 585.000000000000 -1185.00000000000 585.000000000000]
[ 395.000000000000 585.000000000000 15.0000000000000 -1185.00000000000]
sage: M=matrix(QQ,[[-1185,15,1155,585], [395,-1185,15,15], [395,585,-1185,585], [395,585,15,-1185]])
sage: M.echelon_form()
[ 1 0 0 -361677/186440]
[ 0 1 0 -40/59]
[ 0 0 1 -59/40]
[ 0 0 0 0]
sage: v=vector([361677/186440,40/59,59/40,1])
sage: (v/v.norm()).n()
(0.713196892748114, 0.249250262646952, 0.542275102671275, 0.367644137404254)
\end{lstlisting}
\item Page $p_3$ is important, but it passes its importance on to
only one page, $p_1$.
So that page receives a large boost.
\end{exparts}
\end{answer}
\end{exercises}
\index{page ranking|)}
\endinput
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment