<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Dynamical Systems |</title><link>https://kristianeschenburg.netlify.app/tag/dynamical-systems/</link><atom:link href="https://kristianeschenburg.netlify.app/tag/dynamical-systems/index.xml" rel="self" type="application/rss+xml"/><description>Dynamical Systems</description><generator>Source Themes Academic (https://sourcethemes.com/academic/)</generator><language>en-us</language><lastBuildDate>Thu, 24 May 2018 11:30:43 -0700</lastBuildDate><image><url>https://kristianeschenburg.netlify.app/img/Bayes.jpg</url><title>Dynamical Systems</title><link>https://kristianeschenburg.netlify.app/tag/dynamical-systems/</link></image><item><title>Exploring Neurological Dynamical Systems: Part 2</title><link>https://kristianeschenburg.netlify.app/post/exploring-neurological-dynamical-systems-part-2/</link><pubDate>Thu, 24 May 2018 11:30:43 -0700</pubDate><guid>https://kristianeschenburg.netlify.app/post/exploring-neurological-dynamical-systems-part-2/</guid><description>&lt;p>In my previous post on
&lt;a href="https://kristianeschenburg.netlify.app/post/exploring-neurological-dynamical-systems-part-1/">dynamic mode decomposition&lt;/a>, I discussed the foundations of DMD as a means for linearizing a dynamical system&lt;sup id="fnref:1">&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref">1&lt;/a>&lt;/sup>&lt;sup id="fnref:2">&lt;a href="#fn:2" class="footnote-ref" role="doc-noteref">2&lt;/a>&lt;/sup>&lt;sup id="fnref:3">&lt;a href="#fn:3" class="footnote-ref" role="doc-noteref">3&lt;/a>&lt;/sup>. In this post, I want to look at a way in which we can use rank-updates to incorporate new information into the spectral decomposition of our linear operator, $A$, in the event that we are generating online measurements from our dynamical system&lt;sup id="fnref:4">&lt;a href="#fn:4" class="footnote-ref" role="doc-noteref">4&lt;/a>&lt;/sup> &amp;ndash; see the citation below if you want a more-detailed overview of this topic along with open source code for testing this method.&lt;/p>
&lt;p>Recall that we are given an initial data matrix&lt;/p>
&lt;p>$$\begin{align}
X = \begin{bmatrix}
x_{n_{1},m_{1}} &amp;amp; x_{n_{1},m_{2}} &amp;amp; x_{n_{1},m_{3}} &amp;amp; &amp;hellip; \\
x_{n_{2},m_{1}} &amp;amp; x_{n_{1},m_{2}} &amp;amp; x_{n_{2},m_{3}} &amp;amp; &amp;hellip; \\
x_{n_{3},m_{1}} &amp;amp; x_{n_{1},m_{2}} &amp;amp; x_{n_{3},m_{3}} &amp;amp; &amp;hellip; \\
&amp;hellip; &amp;amp; &amp;hellip; &amp;amp; &amp;hellip; &amp;amp; &amp;hellip; \\
\end{bmatrix}
\in R^{n \times m}
\end{align}$$&lt;/p>
&lt;p>which we can split into two matrices, shifted one unit in time apart:&lt;/p>
&lt;p>$$\begin{align}
X^{\ast} &amp;amp;=
\begin{bmatrix}
\vert &amp;amp; \vert &amp;amp; \dots &amp;amp; \vert \\
\vec{x}_1 &amp;amp; \vec{x}_2 &amp;amp; \dots &amp;amp; \vec{x}_{m-1} \\
\vert &amp;amp; \vert &amp;amp; \dots &amp;amp; \vert \\
\end{bmatrix} \in R^{n \times (m-1)} \\
Y &amp;amp;= \begin{bmatrix}
\vert &amp;amp; \vert &amp;amp; \dots &amp;amp; \vert \\
\vec{x}_2 &amp;amp; \vec{x}_3 &amp;amp; \dots &amp;amp; \vec{x}_{m} \\
\vert &amp;amp; \vert &amp;amp; \dots &amp;amp; \vert \\
\end{bmatrix} \in R^{n \times (m-1)}
\end{align}$$&lt;/p>
&lt;p>and we are interested in solving for the linear operator $A$, such that&lt;/p>
&lt;p>$$\begin{align}
Y = AX^{\ast}
\end{align}$$&lt;/p>
&lt;p>For simplicity, since we are no longer using the full matrix, I&amp;rsquo;ll just refer to $X^{\ast}$ as $X$. In the previous post, we made the constraint that $n &amp;gt; m$, and that rank($X$) $\leq m &amp;lt; n$. Here, however, we&amp;rsquo;ll reverse this assumption, such that $m &amp;gt; n$, and that rank($X$) $\leq m &amp;lt; n$, such that $XX^{T}$ is invertible, so by multiplying both sides by $X^{T}$ we have&lt;/p>
&lt;p>$$\begin{align}
AXX^{T} &amp;amp;= YX^{T} \\
A &amp;amp;= YX^{T}(XX^{T})^{-1} \\
A &amp;amp;= QP_{x}
\end{align}$$&lt;/p>
&lt;p>where $Q = YX^{T}$ and $P_{x} = (XX^{T})^{-1}$. Now, let&amp;rsquo;s say you observe some new data $x_{m+1}, y_{m+1}$, and you want to incorporate this new data into your $A$ matrix. As in the previous post on
&lt;a href="https://kristianeschenburg.netlify.app/post/rank-one-updates/">rank-one updates&lt;/a>, we saw that directly computing the inverse could potentially be costly, so we want to refrain from doing that if possible. Instead, we&amp;rsquo;ll use the Sherman-Morrison-Woodbury theorem again to incorporate our new $x_{m+1}$ sample into our inverse matrix, just as before:&lt;/p>
&lt;p>$$\begin{align}
(X_{m+1}X^{T}&lt;em>{m+1})^{-1} = P&lt;/em>{x} + \frac{P_{x}x_{m+1}x_{m+1}^{T}P_{x}}{1 + x_{m+1}^{T}P_{x}x_{m+1}}
\end{align}$$&lt;/p>
&lt;p>Likewise, since we&amp;rsquo;re appending new data to our $Y$ and $X$ matrices, we also have&lt;/p>
&lt;p>$$\begin{align}
Y_{m+1} = \begin{bmatrix}
Y &amp;amp; y_{m+1} \end{bmatrix} \\
X_{m+1} = \begin{bmatrix} \\
X &amp;amp; x_{m+1} \end{bmatrix} \\
\end{align}$$&lt;/p>
&lt;p>such that&lt;/p>
&lt;p>$$\begin{align}
Y_{m+1} X_{m+1}^{T} &amp;amp;= YX^{T} + y_{m+1}x_{m+1}^{T} \\
&amp;amp;= Q + y_{m+1}x_{m+1}^{T}
\end{align}$$&lt;/p>
&lt;p>which is simply the sum of our original matrix $Q$, plus a rank-one matrix. The authors go on to describe some pretty cool &amp;ldquo;local&amp;rdquo; DMD schemes, by incorporating weights, as well as binary thresholds, that are time-dependent into the computation of the linear operator, $A$.&lt;/p>
&lt;div class="footnotes" role="doc-endnotes">
&lt;hr>
&lt;ol>
&lt;li id="fn:1">
&lt;p>P.J. Schmid.
&lt;a href="https://hal-polytechnique.archives-ouvertes.fr/file/index/docid/1020654/filename/DMS0022112010001217a.pdf" target="_blank" rel="noopener">Dynamic mode decomposition of numerical and experimental data&lt;/a>. Journal of Fluid Mechanics 656.1. 2010.&amp;#160;&lt;a href="#fnref:1" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:2">
&lt;p>Tu et al.
&lt;a href="http://cwrowley.princeton.edu/papers/Tu-DMD.pdf" target="_blank" rel="noopener">On Dynamic Mode Decomposition: Theory And Applications&lt;/a>&amp;#160;&lt;a href="#fnref:2" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:3">
&lt;p>Kunert-Graf et al.
&lt;a href="https://www.frontiersin.org/articles/10.3389/fncom.2019.00075/full" target="_blank" rel="noopener">Extracting Reproducible Time-Resolved Resting State Networks Using Dynamic Mode Decomposition&lt;/a>. Front. Comput. Neurosci. 2019.&amp;#160;&lt;a href="#fnref:3" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:4">
&lt;p>Zhang et al.
&lt;a href="https://arxiv.org/abs/1707.02876" target="_blank" rel="noopener">Online dynamic mode decomposition for time-varying systems&lt;/a>. 2017.&amp;#160;&lt;a href="#fnref:4" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;/ol>
&lt;/div></description></item><item><title>Exploring Neurological Dynamical Systems: Part 1</title><link>https://kristianeschenburg.netlify.app/post/exploring-neurological-dynamical-systems-part-1/</link><pubDate>Tue, 22 May 2018 14:02:52 -0700</pubDate><guid>https://kristianeschenburg.netlify.app/post/exploring-neurological-dynamical-systems-part-1/</guid><description>&lt;p>In the next two posts, I want to talk briefly about an algorithm called Dynamic Mode Decomposition (DMD). DMD is a spatiotemporal modal decomposition technique that can be used to identify spatial patterns in a signal (modes), along with the time course of these spatial patterns (dynamics). As such, the algorithm assumes that the input data has both a spatial and a temporal component. We are interested in modeling &lt;em>how&lt;/em> the system evolves over time.&lt;/p>
&lt;p>If you&amp;rsquo;d like to find more information about DMD, Peter Schmid&lt;sup id="fnref:1">&lt;a href="#fn:1" class="footnote-ref" role="doc-noteref">1&lt;/a>&lt;/sup> and Jonathan Tu&lt;sup id="fnref:2">&lt;a href="#fn:2" class="footnote-ref" role="doc-noteref">2&lt;/a>&lt;/sup> have written excellent expositions on the topic. Likewise, if you&amp;rsquo;d like to follow along with the code for the following analysis, see
&lt;a href="https://github.com/kristianeschenburg/dmd" target="_blank" rel="noopener">my repo&lt;/a>. For a more in-depth analysis that applies DMD to brain activity in the resting brain, see a recent publication by my colleagues and me&lt;sup id="fnref:3">&lt;a href="#fn:3" class="footnote-ref" role="doc-noteref">3&lt;/a>&lt;/sup>, along with the
&lt;a href="https://github.com/kunert/DMD_RSN" target="_blank" rel="noopener">code&lt;/a> used for our analysis.&lt;/p>
&lt;h2 id="the-dmd-algorithm">The DMD Algorithm&lt;/h2>
&lt;p>Let&amp;rsquo;s assume that you&amp;rsquo;ve taken $n$ measurements from specific points in space for $m$ time points, where for now we assume that $m\lt n$. For now, we&amp;rsquo;ll assume that the sampling frequency, $\omega$, is stable across the entire experiment. We define our entire data matrix as&lt;/p>
&lt;p>$$\begin{align}
X = \begin{bmatrix}
x_{n_{1},m_{1}} &amp;amp; x_{n_{1},m_{2}} &amp;amp; x_{n_{1},m_{3}} &amp;amp; &amp;hellip; \\
x_{n_{2},m_{1}} &amp;amp; x_{n_{1},m_{2}} &amp;amp; x_{n_{2},m_{3}} &amp;amp; &amp;hellip; \\
x_{n_{3},m_{1}} &amp;amp; x_{n_{1},m_{2}} &amp;amp; x_{n_{3},m_{3}} &amp;amp; &amp;hellip; \\
&amp;hellip; &amp;amp; &amp;hellip; &amp;amp; &amp;hellip; &amp;amp; &amp;hellip; \\
\end{bmatrix}
\in R^{n \times m}
\end{align}$$&lt;/p>
&lt;p>We are interested in solving for the matrix, $A \in R^{n \times n}$, such that&lt;/p>
&lt;p>$$\begin{align}
x_{t+1} = A x_{t} \; \; \forall \; \; t = 1,2,&amp;hellip;m-1
\end{align}$$&lt;/p>
&lt;p>Given our full data matrix $X$, we can define two matrices $X^{*}$ and $Y$ such that&lt;/p>
&lt;p>$$\begin{align}
X^{*} &amp;amp;= \begin{bmatrix}
\vert &amp;amp; \vert &amp;amp; \dots &amp;amp; \vert \\
\vec{x}_{1} &amp;amp; \vec{x}_{2} &amp;amp; \dots &amp;amp; \vec{x}_{m-1} \\
\vert &amp;amp; \vert &amp;amp; \dots &amp;amp; \vert \\
\end{bmatrix} \in R^{n \times (m-1)} \\
Y &amp;amp;= \begin{bmatrix}
\vert &amp;amp; \vert &amp;amp; \dots &amp;amp; \vert \\
\vec{x}_2 &amp;amp; \vec{x}_3 &amp;amp; \dots &amp;amp; \vec{x}_{m} \\
\vert &amp;amp; \vert &amp;amp; \dots &amp;amp; \vert \\
\end{bmatrix} \in R^{n \times (m-1)}
\end{align}$$&lt;/p>
&lt;p>so that we can write&lt;/p>
&lt;p>$$\begin{align}
Y = AX^{\ast}
\end{align}$$&lt;/p>
&lt;p>If $n$ is small, this is relatively easy to compute &amp;ndash; however, if $n$ is large, as is the case when modeling temporal dynamics in resting-state MRI, it would be computationally inefficient to compute A directly. To alleviate this, we can make use of the Singular Value Decomposition (SVD) of our predictor matrix $X^{\ast}$. We define the SVD of $X^{\ast}$ as&lt;/p>
&lt;p>$$\begin{align}
X^{\ast} = U \Sigma V^{T} \
\end{align}$$&lt;/p>
&lt;p>as well as the Moore-Penrose pseudo-inverse of $X^{\ast} = X^{\dagger}$ as&lt;/p>
&lt;p>$$\begin{align}
X^{\dagger} = V \Sigma^{-1} U^{T} \\
\end{align}$$&lt;/p>
&lt;p>such that we can write&lt;/p>
&lt;p>$$\begin{align}
YX^{\dagger} = YV \Sigma^{-1} U^{T} = A X^{\ast}X^{\dagger} = A \\
\end{align}$$&lt;/p>
&lt;p>Additionally, if we assume that $rank(X^{\ast}) = r \leq m$, then we can use the truncated SVD such that&lt;/p>
&lt;p>$$\begin{align}
U &amp;amp; \in R^{n \times r} \\
V^{T} &amp;amp; \in R^{r \times m} \\
\end{align}$$&lt;/p>
&lt;p>and&lt;/p>
&lt;p>$$\begin{align}
\Sigma = \begin{bmatrix}
\sigma_{1} &amp;amp; 0 &amp;amp; 0 &amp;amp; &amp;hellip; \\
0 &amp;amp; \sigma_{2} &amp;amp; 0 &amp;amp; &amp;hellip; \\
0 &amp;amp; 0 &amp;amp; \ddots &amp;amp; &amp;hellip; \\
\vdots &amp;amp; \vdots &amp;amp; \vdots &amp;amp; \sigma_{r} \\
\end{bmatrix} \in R^{r \times r}
\end{align}$$&lt;/p>
&lt;p>As it stands now, we still compute an $A \in R^{n \times n}$ matrix. However, because we have a potentially low-rank system, we can apply a Similarity Transformation to $A$ in order to reduce its dimensionality, without changing its spectrum. Using our spatial singular vectors $U$, we define&lt;/p>
&lt;p>$$\begin{align}
\tilde{A} &amp;amp;= U^{T} A U \\
&amp;amp;= U^{T} (YV \Sigma^{-1} U^{T}) U \\
&amp;amp;= U^{T} Y V \Sigma^{-1} \\
\end{align}$$&lt;/p>
&lt;p>where $\tilde{A} \in R^{r \times r}$. If we consider the above SVD, we see that $U$ is the matrix of left singular vectors, an orthogonal basis that spans $C(X^{\ast})$, which is an r-dimensional subspace of $R^{n}$. Thus, the similarity transform represents a mapping $f(A) = U^{T} A U : R^{n} \rightarrow R^{r}$. We now have a reduced-dimensional representation of our linear operator, from which we can compute the spatial modes and dynamic behavior of each mode. First, however, because of the notion of variance captured by the singular values of our original predictor matrix, we weight $\tilde{A}$ by the singular values as&lt;/p>
&lt;p>$$\begin{align}
\hat{A} = \Sigma^{\frac{1}{2}} \tilde{A} \Sigma^{\frac{1}{2}} \\
\end{align}$$&lt;/p>
&lt;p>such that our computed spatial modes have been weighted by the amount they contribute to our measured signal. We can now compute the eigendecomposition of $\hat{A}$ as&lt;/p>
&lt;p>$$\begin{align}
\hat{A} W = W \Lambda \\
\end{align}$$&lt;/p>
&lt;p>where the eigenvectors $W$ are the reduced-dimension representations of our spatial modes, and the eigenvalues $\Lambda$ capture the dynamic behavior of our spatial modes. Because our original data matrix $X^{\ast}$ had spatial dimension $n$ and our eigenvectors have dimension $r$, we need to up-project our eigenvectors $W$ to compute the final spatial modes, via&lt;/p>
&lt;p>$$\begin{align}
\Phi = Y V \Sigma^{\frac{-1}{2}}W
\end{align}$$&lt;/p>
&lt;p>From the SVD of our prediction matrix $X^\ast=U \Sigma V^{T}$, the matrix $V \in R^{m \times r}$ is the matrix of right singular vectors, an orthogonal basis spanning the space of $X^{\ast T}$ (i.e. $r$ basis vectors spanning the space of the measured time courses). Thus, we see that $H = (V \Sigma^{\frac{-1}{2}})W$ represents a linear combination of the temporal basis vectors (a mapping from $R^{r} \rightarrow R^{m}$) for each eigenvector $w_{i}$ of $W$, weighted by the corresponding singular value $\sigma_{i}^{\frac{-1}{2}}$ (that acts to normalize the spatial mode amplitudes). Finally, we see that $\Phi = X^{\ast}H$ computes how much of each temporal basis vector is present in the measured time course at each point in space.&lt;/p>
&lt;p>Because we are modeling a dynamical system, we can compute the continuous time dynamics of our system using our spatial modes and eigenvalues as&lt;/p>
&lt;p>$$\begin{align}
\vec{x}(t) \approx \sum_{i=1}^{r} b_{i}\exp^{((\gamma_{i} + 2i\pi f_{i})\cdot t)} \vec{\phi}_{i}
\end{align}$$&lt;/p>
&lt;p>where $\gamma_{i}$ is a growth-decay constant and $f_{i}$ is the frequency of oscillation of the spatial mode $\phi_{i}$. We can compute these two constants as&lt;/p>
&lt;p>$$\begin{align}
\gamma_{i} &amp;amp;= \frac{\text{real}(\text{ln}(\lambda_{i}))}{\Delta t} \\
f_{i} &amp;amp;= \frac{\text{imag}(\text{ln}(\lambda_{i}))}{2\pi \Delta t}
\end{align}$$&lt;/p>
&lt;p>So, we can see that DMD linearizes our measured time series, by fitting what can be analogized to a &amp;ldquo;global&amp;rdquo; regression. That is, instead of computing how a single time point predicts the next time point, which could readily be solved using the simple &lt;strong>Normal equations&lt;/strong>, DMD computes how a matrix of time points predicts another matrix of time points that is shifted one unit of time into the future. To this extent, DMD minimizes the Frobenius norm of&lt;/p>
&lt;p>$$\begin{align}
\min \limits_{A} \lVert Y - AX^{\ast} \rVert^{2}_{F} \\
\end{align}$$&lt;/p>
&lt;p>However, rather than explicitly computing the matrix $A$, DMD computes the eigenvectors and eigenvalues of $A$, by utilizing the &lt;strong>Singular Value Decomposition&lt;/strong>, along with a &lt;strong>Similarity Transformation&lt;/strong>, in order to generate a reduced-dimensional representation of $A$.&lt;/p>
&lt;p>This spectral decomposition of our linear operator is of particular importance, because it sheds light on the fact that DMD models the temporal dynamics of our system using a &lt;strong>Fourier basis&lt;/strong>. Each spatial mode is represented by a particular Fourier frequency along with a growth-decay constant that determines the future behavior of our spatial mode. Additionally, the Fourier basis also determines what sorts of time series can be modeled using DMD &amp;ndash; time series that are expected to have sinusoidal behavior will be more reliably modeled using DMD, whereas signals that show abrupt spike patterns might be more difficult to model.&lt;/p>
&lt;div class="footnotes" role="doc-endnotes">
&lt;hr>
&lt;ol>
&lt;li id="fn:1">
&lt;p>P.J. Schmid.
&lt;a href="https://hal-polytechnique.archives-ouvertes.fr/file/index/docid/1020654/filename/DMS0022112010001217a.pdf" target="_blank" rel="noopener">Dynamic mode decomposition of numerical and experimental data&lt;/a>. Journal of Fluid Mechanics 656.1. 2010.&amp;#160;&lt;a href="#fnref:1" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:2">
&lt;p>Tu et al.
&lt;a href="http://cwrowley.princeton.edu/papers/Tu-DMD.pdf" target="_blank" rel="noopener">On Dynamic Mode Decomposition: Theory And Applications&lt;/a>&amp;#160;&lt;a href="#fnref:2" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;li id="fn:3">
&lt;p>Kunert-Graf et al.
&lt;a href="https://www.frontiersin.org/articles/10.3389/fncom.2019.00075/full" target="_blank" rel="noopener">Extracting Reproducible Time-Resolved Resting State Networks Using Dynamic Mode Decomposition&lt;/a>. Front. Comput. Neurosci. 2019.&amp;#160;&lt;a href="#fnref:3" class="footnote-backref" role="doc-backlink">&amp;#x21a9;&amp;#xfe0e;&lt;/a>&lt;/p>
&lt;/li>
&lt;/ol>
&lt;/div></description></item></channel></rss>