2023-10-03 11:23:07 -07:00
|
|
|
\section{Random Walks}
|
|
|
|
|
|
|
|
Consider the graph below. A particle sits on some node $n$. Every second, this particle moves left or
|
|
|
|
right with equal probability. Once it reaches node $A$ or $B$, it stops. \par
|
|
|
|
We would like to compute the probability of our particle stopping at node $A$. \par
|
|
|
|
|
|
|
|
\vspace{2mm}
|
|
|
|
|
2023-10-05 10:45:57 -07:00
|
|
|
In other words, we want a function $P(n): N \to [0, 1]$ that returns the probability that our particle stops at $A$,
|
|
|
|
where $N$ is the set of nodes in $G$.
|
2023-10-03 11:23:07 -07:00
|
|
|
|
|
|
|
\begin{center}
|
|
|
|
\begin{tikzpicture}
|
|
|
|
\begin{scope}[layer = nodes]
|
|
|
|
\node[accept] (a) at (0, 0) {$A$};
|
|
|
|
\node[main] (x) at (2, 0) {$x$};
|
|
|
|
\node[main] (y) at (4, 0) {$y$};
|
|
|
|
\node[reject] (b) at (6, 0) {$B$};
|
|
|
|
\end{scope}
|
|
|
|
|
|
|
|
\draw[-]
|
|
|
|
(a) edge (x)
|
|
|
|
(x) edge (y)
|
|
|
|
(y) edge (b)
|
|
|
|
;
|
|
|
|
\end{tikzpicture}
|
|
|
|
\end{center}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\problem{}<firstgraph>
|
|
|
|
What are $P(A)$ and $P(B)$ in the graph above? \par
|
|
|
|
\note{Note that these values hold for all graphs.}
|
|
|
|
|
|
|
|
\begin{solution}
|
|
|
|
$P(A) = 1$ and $P(B) = 0$
|
|
|
|
\end{solution}
|
|
|
|
|
|
|
|
\vfill
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\problem{}
|
|
|
|
Find an expression for $P(x)$ in terms of $P(y)$ and $P(A)$. \par
|
|
|
|
Find an expression for $P(y)$ in terms of $P(x)$ and $P(B)$. \par
|
|
|
|
|
|
|
|
\begin{solution}
|
|
|
|
$P(x) = \frac{P(A) + P(y)}{2}$
|
|
|
|
|
|
|
|
\vspace{2mm}
|
|
|
|
|
|
|
|
$P(y) = \frac{P(B) + P(x)}{2}$
|
|
|
|
\end{solution}
|
|
|
|
|
|
|
|
\vfill
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\problem{}
|
|
|
|
Use the previous problems to find $P(x)$ and $P(y)$.
|
|
|
|
|
|
|
|
\begin{solution}
|
|
|
|
$P(x) = \nicefrac{2}{3}$
|
|
|
|
|
|
|
|
\vspace{2mm}
|
|
|
|
|
|
|
|
$P(y) = \nicefrac{1}{3}$
|
|
|
|
\end{solution}
|
|
|
|
|
|
|
|
\vfill
|
|
|
|
\pagebreak
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\problem{}<oneunweighted>
|
|
|
|
Say we have a graph $G$ and a particle on node $x$ with neighbors $v_1, v_2, ..., v_n$. \par
|
|
|
|
Assume that our particle is equally likely to travel to each neighbor. \par
|
|
|
|
Find $P(x)$ in terms of $P(v_1), P(v_2), ..., P(v_n)$.
|
|
|
|
|
|
|
|
\begin{solution}
|
|
|
|
We have
|
|
|
|
$$
|
|
|
|
P(x) = \frac{P(v_1) + P(v_2) + ... + P(v_n)}{n}
|
|
|
|
$$
|
|
|
|
\end{solution}
|
|
|
|
|
|
|
|
\vfill
|
|
|
|
|
|
|
|
|
|
|
|
\problem{}
|
|
|
|
How can we use \ref{oneunweighted} to find $P(n)$ for any $n$?
|
|
|
|
|
|
|
|
\begin{solution}
|
|
|
|
If we write an equation for each node other than $A$ and $B$, we have a system of $|N| - 2$
|
|
|
|
linear equations in $|N| - 2$ variables.
|
|
|
|
\end{solution}
|
|
|
|
|
|
|
|
\vfill
|
|
|
|
\pagebreak
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\problem{}
|
|
|
|
Find $P(n)$ for all nodes in the graph below.
|
|
|
|
|
|
|
|
\begin{center}
|
|
|
|
\begin{tikzpicture}
|
|
|
|
\begin{scope}[layer = nodes]
|
|
|
|
\node[accept] (a) at (0, 0) {$A$};
|
|
|
|
\node[main] (x) at (2, 0) {$x$};
|
|
|
|
\node[main] (y) at (0, -2) {$y$};
|
|
|
|
\node[reject] (b) at (2, -2) {$B$};
|
|
|
|
\end{scope}
|
|
|
|
|
|
|
|
\draw[-]
|
|
|
|
(a) edge (x)
|
|
|
|
(x) edge (b)
|
|
|
|
(b) edge (y)
|
|
|
|
(y) edge (a)
|
|
|
|
;
|
|
|
|
\end{tikzpicture}
|
|
|
|
\end{center}
|
|
|
|
|
|
|
|
\begin{solution}
|
|
|
|
$P(x) = \nicefrac{1}{2}$ for both $x$ and $y$.
|
|
|
|
\end{solution}
|
|
|
|
|
|
|
|
\vfill
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\problem{}
|
|
|
|
Find $P(n)$ for all nodes in the graph below. \par
|
|
|
|
\note{Note that this is the graph of a cube with $A$ and $B$ on opposing vertices.}
|
|
|
|
|
|
|
|
\begin{center}
|
|
|
|
\begin{tikzpicture}
|
|
|
|
\begin{scope}[layer = nodes]
|
|
|
|
\node[main] (q) at (0, 0) {$q$};
|
|
|
|
\node[main] (r) at (2, 0) {$r$};
|
|
|
|
\node[main] (s) at (0, -2) {$s$};
|
|
|
|
\node[reject] (b) at (2, -2) {$B$};
|
|
|
|
|
|
|
|
\node[accept] (a) at (-1, 1) {$A$};
|
|
|
|
\node[main] (z) at (3, 1) {$z$};
|
|
|
|
\node[main] (x) at (-1, -3) {$x$};
|
|
|
|
\node[main] (y) at (3, -3) {$y$};
|
|
|
|
\end{scope}
|
|
|
|
|
|
|
|
\draw[-]
|
|
|
|
(a) edge (z)
|
|
|
|
(z) edge (y)
|
|
|
|
(y) edge (x)
|
|
|
|
(x) edge (a)
|
|
|
|
|
|
|
|
(q) edge (r)
|
|
|
|
(r) edge (b)
|
|
|
|
(b) edge (s)
|
|
|
|
(s) edge (q)
|
|
|
|
|
|
|
|
(a) edge (q)
|
|
|
|
(z) edge (r)
|
|
|
|
(y) edge (b)
|
|
|
|
(x) edge (s)
|
|
|
|
;
|
|
|
|
\end{tikzpicture}
|
|
|
|
\end{center}
|
|
|
|
|
|
|
|
|
|
|
|
\begin{solution}
|
|
|
|
$P(z,q, \text{ and } x) = \nicefrac{3}{5}$ \par
|
|
|
|
$P(s,r, \text{ and } y) = \nicefrac{2}{5}$
|
|
|
|
\end{solution}
|
|
|
|
|
|
|
|
\vfill
|
|
|
|
\pagebreak
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\definition{}<weightedgraph>
|
|
|
|
Let us now take a look at weighted graphs. The problem remains the same: we want to compute the probability that
|
|
|
|
our particle stops at node $A$, but our graphs will now feature weighted edges. The probability of our particle
|
|
|
|
taking a certain edge is proportional to that edge's weight.
|
|
|
|
|
|
|
|
\vspace{2mm}
|
|
|
|
|
|
|
|
For example, if our particle is on node $y$ of the graph below, it has a $\frac{3}{8}$ probability of moving
|
|
|
|
to $x$ and a $\frac{1}{8}$ probability of moving to $z$. \par
|
|
|
|
\note{Note that $3 + 3 + 1 + 1 = 8$.}
|
|
|
|
|
|
|
|
|
|
|
|
\begin{center}
|
|
|
|
\begin{tikzpicture}
|
|
|
|
\begin{scope}[layer = nodes]
|
|
|
|
\node[reject] (b) at (0, 0) {$B$};
|
|
|
|
\node[main] (x) at (0, 2) {$x$};
|
|
|
|
\node[main] (y) at (2, 0) {$y$};
|
|
|
|
\node[main] (z) at (4, 0) {$z$};
|
|
|
|
\node[accept] (a) at (3, -2) {$A$};
|
|
|
|
\end{scope}
|
|
|
|
|
|
|
|
\draw[-]
|
|
|
|
(a) edge node[label] {$3$} (y)
|
|
|
|
(y) edge node[label] {$1$} (z)
|
|
|
|
|
|
|
|
(b) edge node[label] {$2$} (x)
|
|
|
|
(x) edge[bend left] node[label] {$3$} (y)
|
|
|
|
(a) edge[bend right] node[label] {$2$} (z)
|
|
|
|
(y) edge node[label] {$1$} (b)
|
|
|
|
;
|
|
|
|
\end{tikzpicture}
|
|
|
|
\end{center}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-10-05 10:45:57 -07:00
|
|
|
\problem{}
|
2023-10-03 11:23:07 -07:00
|
|
|
Say a particle on node $x$ has neighbors $v_1, v_2, ..., v_n$ with weights $w_1, w_2, ..., w_n$. \par
|
|
|
|
The edge $(x, v_1)$ has weight $w_1$. Find $P(x)$ in terms of $P(v_1), P(v_2), ..., P(v_n)$.
|
|
|
|
|
|
|
|
|
|
|
|
\begin{solution}
|
|
|
|
$$
|
|
|
|
P(x) = \frac{w_1 P(v_1) + w_2 P(v_2) + ... + w_n P(v_n)}{w_1 + w_2 + ... + w_n}
|
|
|
|
$$
|
|
|
|
\end{solution}
|
|
|
|
|
|
|
|
\vfill
|
|
|
|
\pagebreak
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\problem{}
|
|
|
|
Consider the following graph. Find $P(x)$, $P(y)$, and $P(z)$.
|
|
|
|
|
|
|
|
\begin{center}
|
|
|
|
\begin{tikzpicture}
|
|
|
|
\begin{scope}[layer = nodes]
|
|
|
|
\node[reject] (b) at (3, 2) {$B$};
|
|
|
|
\node[main] (x) at (0, 0) {$x$};
|
|
|
|
\node[main] (y) at (2, 0) {$y$};
|
|
|
|
\node[main] (z) at (1, 2) {$z$};
|
|
|
|
\node[accept] (a) at (-2, 0) {$A$};
|
|
|
|
\end{scope}
|
|
|
|
|
|
|
|
\draw[-]
|
|
|
|
(x) edge node[label] {$1$} (y)
|
|
|
|
(y) edge node[label] {$1$} (z)
|
|
|
|
(x) edge[bend left] node[label] {$2$} (z)
|
|
|
|
(a) edge node[label] {$1$} (x)
|
|
|
|
(z) edge node[label] {$1$} (b)
|
|
|
|
;
|
|
|
|
\end{tikzpicture}
|
|
|
|
\end{center}
|
|
|
|
|
|
|
|
\begin{solution}
|
|
|
|
$P(x) = \nicefrac{7}{12}$ \par
|
|
|
|
$P(y) = \nicefrac{6}{12}$ \par
|
|
|
|
$P(z) = \nicefrac{5}{12}$
|
|
|
|
\end{solution}
|
|
|
|
|
|
|
|
\vfill
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
\problem{}
|
|
|
|
Consider the following graph. \par
|
|
|
|
What expressions can you find for $P(w)$, $P(x)$, $P(y)$, and $P(z)$?
|
|
|
|
|
|
|
|
\begin{center}
|
|
|
|
\begin{tikzpicture}
|
|
|
|
\begin{scope}[layer = nodes]
|
|
|
|
\node[accept] (a) at (0, 0) {$A$};
|
|
|
|
\node[main] (w) at (2, 1) {$w$};
|
|
|
|
\node[main] (x) at (4, 1) {$x$};
|
|
|
|
\node[main] (y) at (2, -1) {$y$};
|
|
|
|
\node[main] (z) at (4, -1) {$z$};
|
|
|
|
\node[accept] (b) at (6, 0) {$B$};
|
|
|
|
\end{scope}
|
|
|
|
|
|
|
|
\draw[-]
|
|
|
|
(a) edge node[label] {$2$} (w)
|
|
|
|
(a) edge node[label] {$1$} (y)
|
|
|
|
(w) edge node[label] {$2$} (x)
|
|
|
|
(y) edge node[label] {$2$} (z)
|
|
|
|
(x) edge node[label] {$1$} (y)
|
|
|
|
(x) edge node[label] {$1$} (b)
|
|
|
|
(z) edge node[label] {$2$} (b)
|
|
|
|
;
|
|
|
|
\end{tikzpicture}
|
|
|
|
\end{center}
|
|
|
|
|
|
|
|
Solve this system of equations. \par
|
|
|
|
\hint{Use symmetry. $P(w) = 1 - P(z)$ and $P(x) = 1 - P(y)$. Why?}
|
|
|
|
|
|
|
|
\begin{solution}
|
|
|
|
$P(w) = \nicefrac{3}{4}$ \par
|
|
|
|
$P(x) = \nicefrac{2}{4}$ \par
|
|
|
|
$P(y) = \nicefrac{2}{4}$ \par
|
|
|
|
$P(z) = \nicefrac{1}{4}$
|
|
|
|
\end{solution}
|
|
|
|
|
|
|
|
\vfill
|
|
|
|
\pagebreak
|