Added main sections of random walk handout

This commit is contained in:
Mark 2023-10-03 11:23:07 -07:00
parent d0060cfcd5
commit a6a2158ef5
Signed by: Mark
GPG Key ID: AD62BB059C2AAEE4
5 changed files with 693 additions and 0 deletions

28
Advanced/Random Walks/main.tex Executable file
View File

@ -0,0 +1,28 @@
% use [nosolutions] flag to hide solutions.
% use [solutions] flag to show solutions.
\documentclass[
solutions,
singlenumbering
]{../../resources/ormc_handout}
\input{tikxset.tex}
% For \nicefrac
\usepackage{units}
\usepackage{circuitikz}
\uptitlel{Advanced 2}
\uptitler{Fall 2023}
\title{Random Walks and Resistance}
\subtitle{Prepared by Mark on \today{} \\ Based on a handout by Aaron Anderson}
\begin{document}
\maketitle
\input{parts/0 random.tex}
\input{parts/1 circuits.tex}
\input{parts/2 equivalence.tex}
\end{document}

View File

@ -0,0 +1,324 @@
\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}
In other words, we want a function $P(n): N \to [0, 1]$ that returns the probability that our particle stops at $A$.
Naturally, $N$ be the set of nodes in $G$.
\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}
\problem{}<oneunweighted>
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

View File

@ -0,0 +1,131 @@
\section{Circuits}
An \textit{electrical circuit} is a graph with a few extra properties,
called \textit{current}, \textit{voltage}, and \textit{resistance}.
\begin{itemize}[itemsep=3mm]
\item \textbf{Voltage} is a function $V(n): N \to \mathbb{R}$ that assigns a number to each node of our graph. \par
In any circuit, we pick a \say{ground} node, and define the voltage\footnotemark{} there as 0. \par
We also select a \say{source} node, and define its voltage as 1. \par
\vspace{1mm}
Intuitively, you could say we're connecting the ends of a 1-volt battery to our source and ground nodes.
\footnotetext{
In the real world, voltage is always measured \textit{between two points} on a circuit.
Voltage is defined as the \textit{difference} in electrical charge between two points.
Here, all voltages are measured with respect to our \say{ground} node.
This detail isn't directly relevant to the problems in this handout, so you mustn't worry about it today. \par
Just remember that the electrical definitions here are a significant oversimplification of reality.
}
\item \textbf{Current} is a function $I(e^\rightarrow): N \times N \to \mathbb{R}$ that assigns a number to each
\textit{oriented edge} $e^\rightarrow$ in our graph. An \say{oriented edge} is just an ordered pair of nodes $(n_1, n_2)$. \par
\vspace{1mm}
Current through an edge $(a, b)$ is a measure of the flow of charge from $a$ to $b$. \par
Naturally, $I(a, b) = -I(b, a)$.
\item \textbf{Resistance} is a function $R(e): N \times N \to \mathbb{R}^+_0$ that represents a certain edge's
resistance to the flow of current through it. \par
Resistance is a property of each \textit{link} between nodes, so order doesn't matter: $R(a, b) = R(b, a)$.
\end{itemize}
\vspace{2mm}
It is often convenient to compare electrical circuits to systems of pipes. Say we have a pipe from point $A$ to point $B$.
The size of this pipe represents resistance (smaller pipe $\implies$ more resistance), the pressure between $A$ and $B$
is voltage, and the speed water flows through it is to current.
\definition{Ohm's law}
With this \say{pipe} analogy in mind, you may expect that voltage, current, and resistance are related:
if we make our pipe bigger (and change no other parameters), we'd expect to see more current. This is indeed
the case! Any circuit obeys \textit{Ohm's law}, stated below:
$$
V(a, b) = I(a,b) \times R(a,b)
$$
\note{
$V(a, b)$ is the voltage between nodes $a$ and $b$. If this doesn't make sense, read the footnote below. \\
In this handout, it will be convenient to write $V(a, b)$ as $V(a) - V(b)$.
}
\definition{Kirchoff's law}
The second axiom of electrical circuits is also fairly simple. \textit{Kirchoff's law} states that the sum of all currents connected to
a given edge is zero. You can think of this as \say{conservation of mass}: nodes in our circuit do not create or
destroy electrons, they simply pass them around to other nodes.\par
Formally, we can state this as follows:
\vspace{2mm}
Let $x$ be a node in our circuit and $B_x$ the set of its neighbors. We than have
$$
\sum_{b \in B_x} I(x, b) = 0
$$
which must hold at every node \textbf{except the source and ground vertices.} \par
\hint{Keep this exception in mind, it is used in a few problems later on.}
\vfill
\pagebreak
Consider the circuit below. This the graph from \ref{firstgraph}, turned into a circuit by:
\begin{itemize}
\item Replacing all edges with $1\Omega$ resistors
\item Attaching a 1 volt battery between $A$ and $B$
\end{itemize}
\vspace{2mm}
Note that the battery between $A$ and $B$ isn't really an edge.
It exists only to create a potential difference between the two nodes.
\begin{center}
\begin{circuitikz}[american voltages]
\draw
(0,0) node[above left] {$A$ (source)}
to[R, l=$1\Omega$, *-*] (2,0) node[above] {$x$}
to[R, l=$1\Omega$, *-*] (4,0) node[above] {$y$}
to[R, l=$1\Omega$, *-*] (6,0) node[above right] {$B$ (ground)}
to[short] (6, -1) node[below] {$-$}
to[battery,invert,l={1 Volt}] (0, -1) node[below] {$+$}
to[short] (0, 0)
;
\end{circuitikz}
\end{center}
\problem{}<onecurrents>
From the circuit diagram above, we immediatly know that $V(A) = 1$ and $V(B) = 0$. \par
What equations related to the currents out of $x$ and $y$ does Kirchoff's law give us?
\vfill
\problem{}
Use Ohm's law to turn the equations from \ref{onecurrents} into equations about voltage and resistance. \par
Find an expression for $V(x)$ and $V(y)$ in terms of other voltages, then solve the resulting system of equations.
Does your result look familiar?
\begin{solution}
\setlength{\abovedisplayskip}{0pt} % Fix spacing on top
\begin{flalign*}
V(x) &= \frac{V(A) - V(y)}{2} &&\\
V(y) &= \frac{V(x) - V(B)}{2} &&
\end{flalign*}
\end{solution}
\vfill
\pagebreak

View File

@ -0,0 +1,122 @@
\section{The Equivalence}
In the last problem, we found that the equations for $V(x)$ were the same as the equations for $P(x)$ on the same graph.
It turns out that this is true in general: problems about voltage in circuits directly correspond to problems about probability
in graphs. We'll spend the next section proving this fact.
\definition{}
For the following problems, \textit{conductance} will be more convenient than resistance. \par
The definition of conductance is quite simple:
$$
C(a, b) = \frac{1}{R(a,b)}
$$
\note[Aside]{
Resistance is usually measured in Ohms, denoted $\Omega$. \\
A few good-natured physicists came up with the \say{mho} (denoted \reflectbox{\rotatebox[origin=c]{180}{$\Omega$}})
as a unit of conductance, which is equivalent to an inverse Ohm.
Unfortunately, NIST discourages the use of Mhos in favor of the equivalent (and less amusing) \say{Siemens.}
}
\problem{}
Let $x$ be a node in a graph. \par
Let $B_x$ be the set of $x$'s neighbors, $w(x, y)$ the weight of the edge between nodes $x$ and $y$, and $W_x$
the sum of the weights of all edges connected to $x$.
We saw earlier that the probability function $P$ satisfies the following sum:
$$
P(x) = \sum_{b \in B_x} \biggl( P(b) \times \frac{w(x, b)}{W_x} \biggr)
$$
\note{This was never explicitly stated, but is noted in \ref{weightedgraph}.}
\vspace{4mm}
Use Ohm's and Kirchoff's laws to show that the voltage function $V$ satisfies a similar sum:
$$
V(x) = \sum_{b \in B_x} \biggl( V(b) \times \frac{C(x, b)}{C_x} \biggr)
$$
where $C(x, b)$ is the conductance of edge $(x, b)$ and $C_x$ is the sum of the conductances of all edges connected to $x$.
\begin{solution}
First, we know that
$$
\sum_{b \in B_x} I(x, b) = 0
$$
for all nodes $x$. Now, substitute $I(x, b) = \frac{V(x) - V(b)}{R(x, y)}$ and pull out $V(x)$ terms to get
$$
V(x) \sum_{b \in B_x} \frac{1}{R(x, b)} - \sum_{b \in B_x} \frac{V(b)}{R(x, b)} = 0
$$
Rearranging and replacing $R(x, b)^{-1}$ with $C(x, b)$ and $\sum C(x, b)$ with $C_x$ gives us
$$
V(x) = \sum_{b \in B_x} V(b) \frac{C(x, b)}{C_x}
$$
\end{solution}
\vfill
\pagebreak
Thus, if $w(a, b) = C(a, b)$, $P$ and $V$ satisfy the same system of linear equations. To finish proving that
$P = V$, we now need to show that there can only be one solution to this system. We will do this in the next
two problems.
\problem{}<generaleq>
Let $q$ be a solution to the following equations, where $x \neq a, b$.
$$
q(x) = \sum_{b \in B_x} \biggl( q(b) \times \frac{w(x, b)}{W_x} \biggr)
$$
Show that the maximum and minimum of $q$ are $q(a)$ and $q(b)$ (not necessarily in this order).
\begin{solution}
The domain of $q$ is finite, so a maximum and minimum must exist.
\vspace{2mm}
Since $q(x)$ is a weighted average of all $q(b), ~b \in B_x$, there exist $y, z \in B_x$ satisfying
$q(y) \leq q(x) \leq q(z)$. Therefore, none of these can be an extreme point.
\vspace{2mm}
$A$ and $B$ are the only vertices for which this may not be true, so they must be the minimum and maximum.
\end{solution}
\vfill
\problem{}
Let $p$ and $q$ be functions that solve our linear system \par
and satisfy $p(A) = q(A) = 1$ and $p(B) = q(B) = 0$. \par
\vspace{1mm}
Show that the function $p - q$ satisfies the equations in \ref{generaleq}, \par
and that $p(x) - q(x) = 0$ for every $x$. \note{Note that $p(x) - q(x) = 0 ~ \forall x \implies p = q$}
\begin{solution}
The equations in \ref{generaleq} for $p$ and $q$ directly imply that
$$
[p - q](x) = \sum_{b \in B_x} \biggl( [p - q](b) \times \frac{w(x, b)}{W_x} \biggr)
$$
Which are the equations from \ref{generaleq} for $(p - q)$.
\vspace{2mm}
Hence, the minimum and maximum values of $p - q$ are $[p - q](a) = 1 - 1 = 0$
and $[p - q](b) = 1 - 1 = 0$.
\vspace{2mm}
Therefore $p(x) - q(x) = 0$ for all $x$, so $p(x) = q(x)$.
\end{solution}
\vfill
\pagebreak

View File

@ -0,0 +1,88 @@
\usetikzlibrary{arrows.meta}
\usetikzlibrary{shapes.geometric}
\usetikzlibrary{patterns}
% We put nodes in a separate layer, so we can
% slightly overlap with paths for a perfect fit
\pgfdeclarelayer{nodes}
\pgfdeclarelayer{path}
\pgfsetlayers{main,nodes}
% Layer settings
\tikzset{
% Layer hack, lets us write
% later = * in scopes.
layer/.style = {
execute at begin scope={\pgfonlayer{#1}},
execute at end scope={\endpgfonlayer}
},
%
% Arrowhead tweak
>={Latex[ width=2mm, length=2mm ]},
%
% Labels inside edges
label/.style = {
rectangle,
% For automatic red background in solutions
fill = \ORMCbgcolor,
draw = none,
rounded corners = 0mm
},
%
% Nodes
main/.style = {
draw,
circle,
fill = white,
line width = 0.35mm
},
accept/.style = {
draw,
circle,
fill = white,
double,
double distance = 0.5mm,
line width = 0.35mm
},
reject/.style = {
draw,
rectangle,
fill = white,
text = black,
double,
double distance = 0.5mm,
line width = 0.35mm
},
start/.style = {
draw,
rectangle,
fill = white,
line width = 0.35mm
},
%
% Loop tweaks
loop above/.style = {
min distance = 2mm,
looseness = 8,
out = 45,
in = 135
},
loop below/.style = {
min distance = 5mm,
looseness = 10,
out = 315,
in = 225
},
loop right/.style = {
min distance = 5mm,
looseness = 10,
out = 45,
in = 315
},
loop left/.style = {
min distance = 5mm,
looseness = 10,
out = 135,
in = 215
}
}