<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
	<channel>
		<title>SB</title>
		<description>Personal website of SB.</description>
		<link>https://siva82kb.github.io</link>
		<atom:link href="https://siva82kb.github.io/feed.xml" rel="self" type="application/rss+xml" />
		
			<item>
				<title>On Outer Products</title>
				<description>&lt;p&gt;Everyone that has taken linear algebra is quite comfortable with the idea of the standard inner product between two vectors \(\mathbf{x}, \mathbf{y} \in \mathbb{R}^n\).&lt;/p&gt;

\[\mathbf{x}^\top\mathbf{y} = \begin{bmatrix} x_1 &amp;amp; x_2 &amp;amp; \cdots &amp;amp; x_n\end{bmatrix}\begin{bmatrix} y_1 \\ y_2 \\ \vdots \\ y_n\end{bmatrix} = \sum_{i=0}^nx_i\cdot y_i \in \mathbb{R}\]

&lt;p&gt;This is the dot product we use in high school physics and mathematics. This has a nice geometric interpretation as shown in the following figure, where we assume that vector \(\mathbf{x}\) is of unit length, i.e. \(\mathbf{x}^\top\mathbf{x} = 1\).&lt;/p&gt;

&lt;!-- ![innerprod.png](On%20Outer%20Products%204ef1a3a3c30f4ef688a720acfc9cb86d/.png) --&gt;
&lt;p&gt;&lt;img src=&quot;/figs/innerprod.png&quot; alt=&quot;&quot; style=&quot;align: center; margin-left: 5px; margin-right: 10px; margin-top: 7px; width: 300px&quot; /&gt;&lt;/p&gt;

&lt;p&gt;We could this of the number \(\mathbf{x}^\top\mathbf{y}\) as a measure of the amount of information shared by the two vectors \(\mathbf{x}\) and \(\mathbf{y}\). When  \(\mathbf{x}^\top\mathbf{y}=0\) then the two vectors convey mutually exclusive information.&lt;/p&gt;

&lt;p&gt;An innocent little switching of transpose operation in the inner product \(\mathbf{x}^\top\mathbf{y}\) results in a completely different operation that produces an \(n \times n\) matrix!&lt;/p&gt;

\[\mathbf{x}\mathbf{y}^\top = \begin{bmatrix} x_1 \\ x_2 \\ \vdots \\ x_n\end{bmatrix}\begin{bmatrix} y_1 &amp;amp; y_2 &amp;amp; \cdots &amp;amp; y_n \end{bmatrix} = \begin{bmatrix} x_1y_1 &amp;amp; x_1y_2 &amp;amp; \cdots &amp;amp; x_1y_n \\ x_2y_1 &amp;amp; x_2y_2 &amp;amp; \cdots &amp;amp; x_2y_n \\ \vdots &amp;amp; \vdots &amp;amp; \ddots &amp;amp; \vdots \\ x_ny_1 &amp;amp; x_ny_2 &amp;amp; \cdots &amp;amp; x_ny_n \end{bmatrix} \in \mathbb{R}^{n \times n} \tag{1}\]

&lt;p&gt;This matrix can be seen as an operator \(\mathcal{O}\) that maps \(\mathcal{O}: \mathbb{R}^n\mapsto \mathbb{R}^n.\) This is the &lt;strong&gt;outer product&lt;/strong&gt;.  When the vectors are from different spaces, \(\mathbf{x}\in\mathbb{R}^n\) and \(\mathbf{y}\in\mathbb{R}^m\), then \(\mathbf{x}\mathbf{y}^\top\in\mathbb{R}^{n\times m}\), and \(\mathcal{O}: \mathbb{R}^m\mapsto \mathbb{R}^n.\)&lt;/p&gt;

&lt;p&gt;Outer products product rank-1 matrices, and any rank-1 matrix can be represented as an outer product between two vectors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is the geometry associated with the outer product?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;To understand the geometry of the outer product, we will assume that we are only dealing with unit length vectors, \(\Vert \mathbf{u} \Vert = \Vert \mathbf{v} \Vert = 1\). This is because the outer product between two vectors \(\mathbf{u}, \mathbf{v}\) of arbitrary lengths is a scalar multiple of the outer product between the unit vectors along \(\mathbf{u}, \mathbf{v}\),&lt;/p&gt;

\[\mathbf{u}\mathbf{v}^\top = \Vert\mathbf{u}\Vert\cdot\Vert\mathbf{v}\Vert\cdot\left(\frac{\mathbf{u}}{\Vert \mathbf{u} \Vert}\right)\left(\frac{\mathbf{v}}{\Vert \mathbf{v} \Vert}\right)^\top\]

&lt;p&gt;The outer product of a vector \(\mathbf{u}\)  &lt;strong&gt;\(\left( \Vert \mathbf{u} \Vert = 1 \right)\)&lt;/strong&gt; with itself is given by,&lt;/p&gt;

\[\mathbf{u}\mathbf{u}^\top=\begin{bmatrix} u_1^2 &amp;amp; u_1 u_2 &amp;amp; \cdots &amp;amp; u_1u_n \\ u_2u_1 &amp;amp; u_2^2 &amp;amp; \cdots &amp;amp; u_2u_n\\ \vdots &amp;amp; \vdots &amp;amp; \ddots &amp;amp; \vdots\\ u_nu_1 &amp;amp; u_n^2 &amp;amp; \cdots &amp;amp; u_n^2\end{bmatrix}\]

&lt;p&gt;This is the orthogonal projection matrix onto the space spanned by \(\mathbf{u}\), as shown in the following figure. The outer product appears in places involving orthogonal projections.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/figs/outerprod1.png&quot; alt=&quot;&quot; style=&quot;align: center; margin-left: 5px; margin-right: 10px; margin-top: 7px; width: 400px&quot; /&gt;&lt;/p&gt;

&lt;p&gt;What if we wanted to do an orthogonal projection onto a subspace \(\mathcal{S}\) spanned by a set of vectors \(\left\{ \mathbf{x}_1, \mathbf{x}_2, \ldots \mathbf{x}_k \right\}\) that also form an orthonormal basis for \(\mathcal{S}\)?&lt;/p&gt;

&lt;p&gt;We simply form a matrix \(\mathbf{X} = \begin{bmatrix} \mathbf{x}_1 &amp;amp; \mathbf{x}_2 &amp;amp; \cdots &amp;amp; \mathbf{x}_k \end{bmatrix}\) and the orthogonal projection matrix onto \(\mathcal{S}\) is given by,&lt;/p&gt;

\[\mathbf{P}_{\mathcal{S}}=\mathbf{X}\mathbf{X}^\top=\sum_{i=1}^k \mathbf{x}_i\mathbf{x}_i^\top \tag{2}\]

&lt;p&gt;When the basis \(\left\{ \mathbf{x}_1, \mathbf{x}_2, \ldots \mathbf{x}_k \right\}\) of \(\mathcal{S}\) is not orthonormal, the orthogonal projection matrix onto \(\mathcal{S}\) is given by,&lt;/p&gt;

\[\mathbf{P}_{\mathcal{S}} = \mathbf{X}\left(\mathbf{X}^\top\mathbf{X}\right)^{-1}\mathbf{X}^\top \tag{3}\]

&lt;p&gt;This does appear to have the outer product form but there is the strange inverse matrix in the middle. It can be shown that the product of three matrices \(\mathbf{A}\in\mathbb{R}^{n_1\times n_2}, \mathbf{B}\in\mathbb{R}^{n_2\times n_3}, \mathbf{C}\in\mathbb{R}^{n_3\times n_4}\)  can be expressed as the following,&lt;/p&gt;

\[\mathbf{ABC} = \sum_{i=1}^{n_2}\sum_{j=1}^{n_3} b_{ij}\cdot \mathbf{a}_i\tilde{\mathbf{c}}_j^\top \tag{4}\]

&lt;p&gt;where,&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;\(\mathbf{a}_i\) are the columns of \(\mathbf{A}\).&lt;/li&gt;
  &lt;li&gt;\(\tilde{\mathbf{c}}_j^\top\) are the rows of \(\mathbf{C}\), and&lt;/li&gt;
  &lt;li&gt;\(b_{ij}\) is the element in the \(i^{th}\) row and \(j^{th}\) column of \(\mathbf{B}\).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The product of these three matrices is the weighted linear combination of the outer product of the columns \(\mathbf{A}\) and the rows of \(\mathbf{C}\).&lt;/p&gt;

&lt;p&gt;Let \(\mathbf{B}=\left(\mathbf{X}^\top\mathbf{X}\right)^{-1}\), then we have&lt;/p&gt;

\[\mathbf{P}_{\mathcal{S}}=\mathbf{X}\left(\mathbf{X}^\top\mathbf{X}\right)^{-1}\mathbf{X}^\top=\sum_{i=1}^{k}\sum_{j=1}^{k} b_{ij} \mathbf{x}_i\mathbf{x}_j^\top \tag{5}\]

&lt;p&gt;We again see that outer products come into the picture when dealing with orthogonal projection. Here, all possible \(k^2\) outer products are considered when the basis is not orthonormal. Equation (2) is a special case of Equation (5); when the basis is orthonormal the matrix \(\mathbf{X}^\top\mathbf{X}=\mathbf{I}_k\), which leaves only the outer products of the form \(\mathbf{x}_i\mathbf{x}_i^\top\).&lt;/p&gt;

&lt;p&gt;We can think of the outer product \(\mathbf{u}\mathbf{v}^\top\) as a generalization of the orthogonal projection that we get with \(\mathbf{v}\mathbf{v}^\top\). I found a beautiful answer on StackOverflow about this &lt;a href=&quot;https://math.stackexchange.com/questions/965633/is-there-a-geometric-meaning-to-the-outer-product-of-two-vectors&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Consider three vectors, \(\mathbf{u}, \mathbf{v}, \mathbf{x} \in \mathbb{R}^n\),  where \(\Vert \mathbf{u} \Vert = \Vert \mathbf{v} \Vert = 1\), then&lt;/p&gt;

\[\left(\mathbf{u}\mathbf{v}^\top\right)\mathbf{x} = \left(\mathbf{v}^\top \mathbf{x}\right)\mathbf{u}\]

&lt;p&gt;The outer product \(\mathbf{u}\mathbf{v}^\top\) is a matrix that help compute the component of \(\mathbf{x}\) along the \(\mathbf{v}\) direction taken along the \(\mathbf{u}\) direction. When \(\mathbf{u} = \mathbf{v}\), then this corresponds to the orthogonal projection operation, i.e. the component of \(\mathbf{x}\) along \(\mathbf{u}\), taken along \(\mathbf{u}\). This is demonstrated in the following figure.&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/figs/outerprod2.png&quot; alt=&quot;&quot; style=&quot;align: center; margin-left: 5px; margin-right: 10px; margin-top: 7px; width: 400px&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The process of computing the components along one set of vectors and taking those components along another set of vectors is done by linear transformation represented by a matrix \(\mathbf{A}\).&lt;/p&gt;

&lt;p&gt;Consider any matrix \(\mathbf{A} \in \mathbb{R}^{n \times m}\) of rank \(k\), which can be thought of as a linear transformation from  \(\mathbb{R}^m\) to \(\mathbb{R}^n\). We can express this matrix using the SVD as the following,&lt;/p&gt;

\[\mathbf{A}=\mathbf{U}\mathbf{\Sigma}\mathbf{V}^\top, \quad \mathbf{U}\in\mathbb{R}^{n \times k}, \,\, \mathbf{V} \in \mathbb{R}^{m \times k}, \mathbf{\Sigma} \in \mathbb{R}^{k \times k}\]

\[\mathbf{A}=\sum_{i=1}^k\sigma_i\mathbf{u}_i\mathbf{v
}_i^\top\]

&lt;p&gt;The columns of \(\mathbf{V}\) form an orthonormal basis for the row space of \(\mathbf{A}\) and the columns of \(\mathbf{U}\) form an orthonormal basis of the column space of \(\mathbf{A}\).  We could view the linear transformation performed by \(\mathbf{A}\) on a vector \(\mathbf{x}\in \mathbb{R}^m\) as the following,&lt;/p&gt;

&lt;ol&gt;
  &lt;li&gt;Find the components of the vector \(\mathbf{x}\) onto the right singular vectors \(\left\{\mathbf{v}_i\right\}_{i=1}^m\).&lt;/li&gt;
  &lt;li&gt;Scale the individual components by the singular values \(\left\{\sigma_i\right\}_{i=1}^k\) .&lt;/li&gt;
  &lt;li&gt;Compute the components along the left singular vectors \(\left\{\mathbf{u}_i\right\}_{i=1}^k\) using the scaling factor \(\left\{\sigma_i\mathbf{v}_i^\top\mathbf{x}\right\}_{i=1}^k\).&lt;/li&gt;
  &lt;li&gt;Add these components to compute \(\mathbf{Ax}\).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In fact, we can think of the linear transformation performed by an matrix \(\mathbf{A}\) in a similar way when we can decompose the matrix as a product of two matrics, such as the LU decomposition,&lt;/p&gt;

\[\mathbf{A}=\mathbf{L}\mathbf{U}=\hat{\mathbf{L}}\mathbf{D}\hat{\mathbf{U}} = \sum_i d_i  \mathbf{l}_i \tilde{\mathbf{u}}_i^\top\]

&lt;ul&gt;
  &lt;li&gt;\(\mathbf{l}_i\)  are the columns of \(\hat{\mathbf{L}}\)  that form a basis for the column space of \(\mathbf{A}\), with unit length.&lt;/li&gt;
  &lt;li&gt;\(\tilde{\mathbf{u}}_i^\top\) are the rows of \(\hat{\mathbf{U}}\) that form a basis for the row space of \(\mathbf{A}\), with unit length.&lt;/li&gt;
  &lt;li&gt;\(\mathbf{D}\) is a diagonal matrix with the scaling factors.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The outer product is an fundamental operation in linear transformation. It allows us to represent and understand linear transformations as a superposition of simple transformations represented by rank-1 matrices.&lt;/p&gt;
</description>
				<pubDate>Sun, 28 May 2023 14:31:00 +0000</pubDate>
				<link>https://siva82kb.github.io/2023/05/On-Outer-Products</link>
				<guid isPermaLink="true">https://siva82kb.github.io/2023/05/On-Outer-Products</guid>
			</item>
		
			<item>
				<title>Understanding matrix inverses - II: Tall matrices</title>
				<description>&lt;p&gt;\(\newcommand{\mf}{\mathbf} \newcommand{\mb}{\mathbb} \newcommand{\mc}{\mathcal}\)
For full (column or row) rank non-square matrices \(\mf{A} \in \mb{R}^{n \times m}\), we can still have inverses but there are some peculiarities:&lt;/p&gt;
&lt;ol&gt;
  &lt;li&gt;We can only have left or right inverses, as is described below, and&lt;/li&gt;
  &lt;li&gt;The left and right inverses are not unique.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;We will talk about the inverses of tall matrices in this post, i.e. matrices where $n &amp;gt; m$. Tall full rank matrices only have left inverses:&lt;/p&gt;

\[n &amp;gt; m, \,\, rank\left(\mf{A}\right) = m \implies \exists \mf{B} \in \mb{R}^{m \times n} \,\, s.t. \,\, \mf{B} \mf{A} = \mf{I}_{m}\]

&lt;p&gt;This means that, $\mf{B}\mf{A}\mf{x} = \mf{B}\mf{y} \implies \mf{x} = \mf{B}\mf{y}$.&lt;/p&gt;

&lt;p&gt;What $\mf{x}$ represents depends on whether or not $\mf{y}$ is in the column space of $\mf{A}$.&lt;/p&gt;

&lt;ul&gt;
  &lt;li&gt;$\mf{y} \in \mc{C}\left( \mf{A} \right) \implies $ $\mf{x} = \mf{B}\mf{y}$ is the representation of $\mf{y}$ in the &lt;em&gt;column basis&lt;/em&gt; of $\mf{A}$.&lt;/li&gt;
  &lt;li&gt;$\mf{y} \notin \mc{C}\left( \mf{A} \right) \implies $  $\mf{x} = \mf{Bb}$ is the representation of some vector $\hat{\mf{y}}$ $=$ $\mf{A}\mf{x} = \mf{ABb}$, which in the &lt;em&gt;column basis&lt;/em&gt; of $\mf{A}$.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When $\mf{x}$ is substituted back into the original equation, we get&lt;/p&gt;

\[\begin{cases}
\mf{y} \in \mc{C}\left(\mf{A}\right) &amp;amp;\implies \hat{\mf{y}} = \mf{A}\left(\mf{B}\mf{y}\right) = \mf{y} \\
\mf{y} \notin \mc{C}\left(\mf{A}\right) &amp;amp;\implies \hat{\mf{y}} = \mf{A}\left(\mf{B}\mf{y}\right) \neq \mf{y}
\end{cases}\]

&lt;p&gt;For a given left inverse $\mf{B}$, adding a matrix $\mf{C}$ whose rows are orthogonal to the columns of $\mf{A}$ will result in another left inverse of $\mf{A}$.&lt;/p&gt;

\[\left( \mf{B} + \mf{C} \right) \mf{A} = \mf{I}_m, \, s.t. \, \mf{C}\mf{A} = \mf{0}\]

&lt;p&gt;The rows of $\mf{C}$ will be vectors from $\mc{N}\left(\mf{A}^\top\right)$ - the left nullspace of $\mf{A}$. Thus, it is clear that there are infinitely many left inverses for $\mf{A}$.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What do all these left inverse matrices do?&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
  &lt;p&gt;A left inverse allows us to find the representation of \(\hat{\mf{y}}\) – a component of \(\mf{y}\) in \(\mc{C}\left(\mf{A}\right)\) – in the &lt;em&gt;column basis&lt;/em&gt; of \(\mf{A}\).&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;These components are oblique projections onto \(\mc{C}\left(\mf{A}\right)\) along a complementary subspace to \(\mc{C}\left(\mf{A}\right)\) in \(\mb{R}^n\). The matrix \(\mf{A}\left( \mf{B} + \mf{C}\right)\) is this oblique projection matrix.&lt;/p&gt;

\[\hat{\mf{y}} = \mf{A}\left(\mf{B} + \mf{C}\right) \mf{y}\]

&lt;p&gt;In the absence of a mathetical proof of this, let’s convince ourselves that this is true through a simple example. Let \(\mf{A} = \begin{bmatrix} 1 \\ 1\end{bmatrix}\). The following are the various possible left inverses of \(\mf{A}\),&lt;/p&gt;

\[\mf{B} + \mf{C} = \begin{bmatrix} \mf{\tilde{b}}_1^\top \end{bmatrix} + \begin{bmatrix} \mf{\tilde{c}}_1^\top \end{bmatrix} = \frac{1}{2}\begin{bmatrix} 1 &amp;amp; 1 \end{bmatrix} + \begin{bmatrix} \alpha &amp;amp; -\alpha \end{bmatrix}\]

&lt;p&gt;The following figures depicts this particular example,&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/figs/leftinv1.png&quot; alt=&quot;&quot; style=&quot;float: left; margin-left: 5px; margin-right: 10px; margin-top: 7px; width: 300px&quot; /&gt;&lt;/p&gt;

&lt;p&gt;In this figure, we have assumed \(\alpha = -1 \implies \mf{\tilde{c}}_1 = \begin{bmatrix} -1 \\ 1\end{bmatrix}\), and \(\mf{y} = \begin{bmatrix} 1 \\ 2\end{bmatrix}\). Thus,&lt;/p&gt;

\[\begin{split}
\hat{\mf{y}} &amp;amp;= \mf{A} \left( \mf{B} + \mf{C}\right) \mf{y} \\
             &amp;amp;= \begin{bmatrix} 1 \\ 1\end{bmatrix} \begin{bmatrix} -\frac{1}{2}  &amp;amp; \frac{3}{2}\end{bmatrix} \begin{bmatrix} 1 \\ 2\end{bmatrix} \\
             &amp;amp;= \begin{bmatrix} \frac{5}{2} \\ \frac{5}{2} \end{bmatrix}
             \end{split}\]

&lt;p&gt;\(\hat{\mf{y}}\) is the oblique projection of \(\mf{y}\) onto \(\mc{C}\left(\mf{A}\right)\) along the subspace parallel to the dashed black line joining \(\mf{y}\) and \(\hat{\mf{y}}\) in the above figure. This is the subspace spanned by the vector \(\mf{y} - \hat{\mf{y}} = \begin{bmatrix} \frac{3}{2} \\ \frac{1}{2} \end{bmatrix}\). It is important to that \(\mf{\tilde{b}}_1 + \mf{\tilde{c}}_1\) is orthogonal to \(\mf{y} - \hat{\mf{y}}\).&lt;/p&gt;

\[\left( \mf{\tilde{b}}_1 + \mf{\tilde{c}}_1\right)^\top\left( \mf{y} - \hat{\mf{y}} \right) = 0\]

&lt;p&gt;The following examples demonstrates the same for a different value of \(\alpha = 2.5\).&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/figs/leftinv2.png&quot; alt=&quot;&quot; style=&quot;align: center; margin-left: 5px; margin-right: 10px; margin-top: 7px; width: 400px&quot; /&gt;&lt;/p&gt;

&lt;p&gt;It is left as an exercise to work out the different components and verfiy that \(\left( \mf{\tilde{b}}_1 + \mf{\tilde{c}}_1\right) \perp \left(\mf{y} - \hat{\mf{y}}\right)\).&lt;/p&gt;

&lt;p&gt;For any choice of \(\alpha\) we can get a oblique project matrix onto \(\mc{C}\left(\mf{A}\right)\) along a subspace orthogonal to that of \(\mc{C}\left(\mf{B}^\top + \mf{C}^\top\right)\), i.e. the row space of the left inverse.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A special left inverse.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Among the infintely many oblique projectors, the orthogonal projector is a speical one. The left inverse of \(\mf{A}\) that will allow us to do orthogonal projection is the &lt;em&gt;Moore-Penrose Inverse&lt;/em&gt; or the &lt;em&gt;Pseudoinverse&lt;/em&gt;, expressed as \(\mf{A}^\dagger\).&lt;/p&gt;

\[\mf{A}^\dagger = \left(\mf{A}^\top\mf{A}\right)^{-1}\mf{A}^\top\]

&lt;p&gt;The matrix \(\mf{B} = \begin{bmatrix} \mf{\tilde{b}}_1^\top \end{bmatrix}  = \frac{1}{2}\begin{bmatrix} 1 &amp;amp; 1 \end{bmatrix}\) shown in the above figures is the &lt;em&gt;pseudoinverse&lt;/em&gt; of \(\mf{A}\).&lt;/p&gt;

&lt;p&gt;&lt;img src=&quot;/figs/left_pinv.png&quot; alt=&quot;&quot; style=&quot;align: center; margin-left: 5px; margin-right: 10px; margin-top: 7px; width: 600px&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The mapping performed by the psuedoinverse \(\mathbf{A}^\dagger\) is shown in the above figure.&lt;/p&gt;

&lt;p&gt;How do know that this is in fact a orthogonal projector?&lt;/p&gt;

&lt;p&gt;\(\mc{C}\left(\left(\mf{A}^\dagger\right)^\top\right) = \mc{C}\left(\mf{A}\right)\), which means that the matrix \(\mf{A}\mf{A}^\dagger\) is the projection matrix onto \(\mc{C}\left( \mf{A} \right)\) along the subspace orthogonal to \(\mc{C}\left(\mf{A}\right)\), which is \(\mc{N}\left(\mf{A}^\top\right)\).&lt;/p&gt;

&lt;p&gt;I hope this short presentaion helps shed some light on the geometry operation behind left inverses. The next part of this series will focus on the right inverse.&lt;/p&gt;
</description>
				<pubDate>Sun, 12 Sep 2021 14:31:00 +0000</pubDate>
				<link>https://siva82kb.github.io/2021/09/understanding-matrix-inverses-ii</link>
				<guid isPermaLink="true">https://siva82kb.github.io/2021/09/understanding-matrix-inverses-ii</guid>
			</item>
		
			<item>
				<title>Understanding matrix inverses - Part I: Square matrices</title>
				<description>&lt;p&gt;Matrices are a representation of &lt;strong&gt;linear maps&lt;/strong&gt; between finite-dimensional vector spaces. Consider a  linear map \(\mathcal{L}\) from \(\mathbb{R}^m\) to \(\mathbb{R}^n\).&lt;/p&gt;

\[\mathcal{L}: \mathbb{R}^m \mapsto \mathbb{R}^n\]

&lt;p&gt;This linear map can be represented using a real matrix \(\mathbf{A} \in \mathbb{R}^{n \times m}\), such that&lt;/p&gt;

\[\mathbf{y} = \mathcal{L}\left( \mathbf{x} \right) = \mathbf{A}\mathbf{x}, \quad \mathbf{x} \in \mathbb{R}^m, \, \mathbf{y} \in \mathbb{R}^n\]

&lt;p&gt;When the domain and range spaces are the same, then \(\mathbf{A}\) is a square matrix.&lt;/p&gt;

&lt;p&gt;The matrix \(\mathbf{A}\) has a unique inverse \(\mathbf{A}^{-1}\), if and only if the \(\mathbf{A}\) is full-rank, i.e. the columns of the matrix form a basis for \(\mathbb{R}^n\). In this case, \(\mathbf{A}^{-1}\mathbf{A} = \mathbf{A}\mathbf{A}^{-1} = \mathbf{I}_n\), where \(\mathbf{I}_n\) is the \(n \times n\) identity matrix.&lt;/p&gt;

&lt;h3 id=&quot;matrix-inverses-allow-us-to-change-basis&quot;&gt;Matrix inverses allow us to change basis&lt;/h3&gt;

&lt;p&gt;Consider the equation, \(\mathbf{A}\mathbf{x} = \mathbf{y}\). This equation says that the vector \(\mathbf{y}\) is a linear combination of the columns of \(\mathbf{A}\), with the weight for each column given by the elements of \(\mathbf{x}\).&lt;/p&gt;

\[\mathbf{y} = \mathbf{A}\mathbf{x} = \begin{bmatrix} \mathbf{a}_1 &amp;amp; \mathbf{a}_2 &amp;amp; \cdots &amp;amp; \mathbf{a}_n\end{bmatrix} \begin{bmatrix} x_1 \\ x_2 \\ \vdots \\ x_n\end{bmatrix} = \sum_{i=1}^n x_i\mathbf{a}_i\]

&lt;p&gt;Here, \(\mathbf{x}\) is the representation of the vector \(\mathbf{y}\) in the basis of \(\mathbb{R}^n\) formed by the columns of \(\mathbf{A}\) (we will refer to this basis as the &lt;em&gt;column basis&lt;/em&gt;). Given \(\mathbf{A}\) and \(\mathbf{y}\), we can solve for \(\mathbf{x}\) using the inverse of \(\mathbf{A}\),&lt;/p&gt;

\[\mathbf{x} = \mathbf{A}^{-1}\mathbf{y}\]

&lt;p&gt;Thus, we see that \(\mathbf{A}^{-1}\) is the matrix that allows us to change the representation of a vector to the &lt;em&gt;column basis&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Structure of a matrix inverse&lt;/strong&gt;
Let us express $\mathbf{A}^{-1}$ as a column of rows.&lt;/p&gt;

\[\mathbf{A} = \begin{bmatrix} \mathbf{a}_1 &amp;amp; \mathbf{a}_2 &amp;amp; \ldots &amp;amp; \mathbf{a}_n \end{bmatrix} \longrightarrow \mathbf{A}^{-1} = \begin{bmatrix} \mathbf{\tilde{b}}_1^\top \\ \mathbf{\tilde{b}}_2^\top \\ \vdots \\ \mathbf{\tilde{b}}_n^\top\end{bmatrix}\]

&lt;p&gt;Let \(\mathbf{A} = \begin{bmatrix} 1 &amp;amp; 1\\ 0 &amp;amp; 1 \end{bmatrix} = \begin{bmatrix} \mathbf{a}_1 &amp;amp; \mathbf{a}_2 \end{bmatrix}\), then \(\mathbf{A}^{-1} = \begin{bmatrix} 1 &amp;amp; -1 \\ 0 &amp;amp; 1\end{bmatrix} = \begin{bmatrix} \mathbf{\tilde{b}_1^\top} \\ \mathbf{\tilde{b}_2^\top}\end{bmatrix}\). Here,&lt;/p&gt;

\[\mathbf{\tilde{b}}_1^\top \mathbf{a}_1 = \mathbf{\tilde{b}}_2^\top \mathbf{a}_2 = 1 \quad \text{and} \quad \mathbf{\tilde{b}}_1^\top \mathbf{a}_2 = \mathbf{\tilde{b}}_2^\top \mathbf{a}_1 = 0\]

&lt;p&gt;&lt;img src=&quot;/figs/invbasis.png&quot; alt=&quot;&quot; style=&quot;float: left; margin-left: 5px; margin-right: 10px; margin-top: 7px; width: 200px&quot; /&gt;&lt;/p&gt;

&lt;p&gt;The components of $\mathbf{y}$ in &lt;em&gt;column basis&lt;/em&gt; is given by, \(\mathbf{x} = \begin{bmatrix} x_1 \\ x_2 \end{bmatrix} = \mathbf{A}^{-1}\mathbf{y}\).&lt;/p&gt;

\[x_1 = \mathbf{\tilde{b}}_1^\top \mathbf{y} \quad \quad x_2 = \mathbf{\tilde{b}}_2^\top \mathbf{y}\]

&lt;p&gt;Here, $\mathbf{y}_1 = x_1 \mathbf{y}$ is the oblique projection of $\mathbf{y}$ onto the subspace spanned by $\mathbf{a}_1$, along the subspace spanned by $\mathbf{a}_2$. The scaling factor $x_1$ for this oblique projection is obtained by taking the inner product of $\mathbf{y}$ with $\mathbf{\tilde{b}}_1$.&lt;/p&gt;

&lt;p&gt;Similarly, $\mathbf{y}_2 = x_2 \mathbf{a}_2$ is the oblique projection of $\mathbf{y}$ onto the subspace spanned by $\mathbf{a}_2$ along the subspace spanned by $\mathbf{a}_1$. $x_2$ is obtained by taking the inner product of $\mathbf{y}$ with $\mathbf{\tilde{b}}_2$.&lt;/p&gt;

&lt;p&gt;This can be generalized to a $n \times n$ square matrix $\mathbf{A}$.&lt;/p&gt;

&lt;p&gt;The oblique projection of $\mathbf{y}$ onto \(span\left( \{ \mathbf{a}_i \}\right)\) along \(span\left( \{ \mathbf{a}_j \}_{j=1, j \neq i}^{n}\right)\) is obtained by computing the scaling factor $x_i$ as the following,&lt;/p&gt;

\[x_i = \mathbf{\tilde{b}}_i^\top \mathbf{y}\]

\[\mathbf{y}_i = x_i \mathbf{a}_i = \left( \mathbf{\tilde{b}}_i^\top \mathbf{y} \right) \mathbf{a}_i = \left( \mathbf{a}_i \mathbf{\tilde{b}}_i^\top \right) \mathbf{y} = \mathbf{P}_i \mathbf{y}\]

&lt;p&gt;Note: \(span\left( \{ \mathbf{a}_j \}_{j=1, j \neq i}^{n}\right)\) is the subspace spanned by the columns of \(\mathbf{A}\) except \(\mathbf{a}_i\).&lt;/p&gt;

&lt;p&gt;\(\mathbf{P}_i = \mathbf{a}_i \mathbf{\tilde{b}}_i^\top\) is the projection matrix that does oblique projections onto \(span\left( \{ \mathbf{a}_i \}\right)\) along \(span\left( \{ \mathbf{a}_j \}_{j=1, j \neq i}^{n}\right)\).&lt;/p&gt;

\[\mathbf{x} = \begin{bmatrix} x_1 \\ x_2 \\ \vdots \\ x_n \end{bmatrix} = \mathbf{A}^{-1} \mathbf{y} = \begin{bmatrix} \mathbf{\tilde{b}}_1^\top \\ \mathbf{\tilde{b}}_2^\top \\ \vdots \\ \mathbf{\tilde{b}}_n^\top \end{bmatrix} \mathbf{y} = \begin{bmatrix} \mathbf{\tilde{b}}_1^\top \mathbf{y} \\ \mathbf{\tilde{b}}_2^\top \mathbf{y} \\ \vdots \\ \mathbf{\tilde{b}}_n^\top \mathbf{y} \end{bmatrix}\]

&lt;p&gt;The matrix \(\mathbf{P}_{1:r} = \sum_{i=1}^{r} \mathbf{P}_i = \sum_{i=1}^{r} \mathbf{a}_i \mathbf{\tilde{b}}_i^\top\) is the oblique projection matrix onto \(span\left( \{ \mathbf{a}_i \}_{i=1}^{r}\right)\) along \(span\left( \{ \mathbf{a}_i \}_{i=r+1}^{n}\right)\).&lt;/p&gt;

&lt;p&gt;Taking the inner product with the rows \(\left\{ \mathbf{\tilde{b}}_i^\top \right\}_{i=1}^r\) will give us the scaling factors required to obtain the oblique projection along the subspace that is orthogonal to \(span\left( \left\{ \mathbf{\tilde{b}}_i \right\}_{i=1}^r \right)\), which is \(span\left( \left\{ \mathbf{a}_i \right\}_{i=r+1}^n\right)\). This fact will come in handy in understanding the geometric operations performed by left inverses.&lt;/p&gt;

&lt;p&gt;In the next two parts of the blog on matrix inverses, we will go into the details of left and right inverses of full rank rectangular matrices.&lt;/p&gt;
</description>
				<pubDate>Thu, 09 Sep 2021 14:31:00 +0000</pubDate>
				<link>https://siva82kb.github.io/2021/09/understanding-matrix-inverses-i</link>
				<guid isPermaLink="true">https://siva82kb.github.io/2021/09/understanding-matrix-inverses-i</guid>
			</item>
		
			<item>
				<title>Representation of Numbers in Computers - I: Whole numbers and Integers</title>
				<description>&lt;p&gt;I have long wanted to write something about the different binary number representations used in a computer, along their corresponding arithmetic operations. I would have loved to have stumbled upon something like this during my undergraduate years. So, I hope that this will be useful for others who might be looking for a short tutorial-like material on numerical data types used in a computer, in particular &lt;em&gt;integers&lt;/em&gt;, &lt;em&gt;fixed-point&lt;/em&gt;, and &lt;em&gt;floating-point&lt;/em&gt; numbers. In this two part blog-post, I first write about the representation of whole numbers and integers, along with the details of how to add and multiply them.&lt;/p&gt;

&lt;h3 id=&quot;whole-numbers&quot;&gt;Whole Numbers&lt;/h3&gt;
&lt;p&gt;The binary representation of &lt;em&gt;whole numbers&lt;/em&gt; is something all of us are familiar with. In the decimal system, the number two hundred and thirty five is represented as the following,&lt;/p&gt;

\[235 = 2 \times 10^2 + 3 \times 10^1 + 5 \times 10^0\]

&lt;p&gt;In the decimal system, the base is 10 and 10 unique (decimal) digits $0-9$ are used for representing all numbers.&lt;/p&gt;

&lt;p&gt;In the binary system, this number has the following representation, where the base is 2 and the digits 0 and 1 are used.&lt;/p&gt;

\[\begin{split}
235 =&amp;amp; 1 \times 2^7 + 1 \times 2^6 + 1 \times 2^5 + 0 \times 2^4 + \\
&amp;amp; 1 \times 2^3 + 0 \times 2^2 + 1 \times 2^1 + 1 \times 2^0 \\
=&amp;amp; \left[ 11101011 \right]_2 
\end{split}\]

&lt;p&gt;(Note: \(\left[\cdot\right]_2\) &lt;em&gt;indicates that the number in the square brackets is a binary number. We will use this representation only when there is ambiquity regarding the base of a number.&lt;/em&gt;)&lt;/p&gt;

&lt;p&gt;A $n$ bit binary number $B$ is written as $B = \left[ b_{n-1}b_{n-2} \ldots b_1b_0 \right]_2$, where $b_i \in [0, 1], \, 0 \leq i \leq n-1$. Let $d(\cdot)$ be the function that coverts a binary number $B$ to its decimal equivalent, \(d(B) = \sum_{i=0}^{n-1} b_i \times 2^i\).&lt;/p&gt;
&lt;style&gt;
div .textbox {
  width: 100%;
  background-color: #fee;
  padding: 5px;
  border: 0px solid gray;
  margin-bottom: 10px;
  text-align: left;
}
&lt;/style&gt;

&lt;center&gt;
&lt;div class=&quot;textbox&quot;&gt;
&lt;b&gt;Prove:&lt;/b&gt; &lt;i&gt;The maximum whole number that can be represented by a $n$-bit number is $2^n - 1$.&lt;/i&gt;
&lt;/div&gt;  
&lt;/center&gt;

&lt;p&gt;Arithmetic operations on binary numbers are carried out exactly the way we perform decimal arithmetic. We will only consider the addition and multiplication operations here, as the set of whole numbers are not closed under the subtraction and division operations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Binary Addition&lt;/strong&gt; can be carried out with the knowledge of the following truth table. Addition of two $n$ bit binary numbers $A$ and $B$ can result in a binary number $C = A + B$ with at most $n+1$ bits.&lt;/p&gt;

&lt;style type=&quot;text/css&quot;&gt;
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:2px 2px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:2px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg .tg-baqh{text-align:center;vertical-align:top}
.tg .tg-c3ow{border-color:inherit;text-align:center;vertical-align:top}
.tg .tg-7btt{font-weight:bold;border-color:inherit;text-align:center;vertical-align:top}
&lt;/style&gt;

&lt;center&gt;
&lt;table class=&quot;tg&quot;&gt;
  &lt;tr&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;A&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;B&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;C = A + B&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;C = A x B&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;0&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;0&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;00&lt;sub&gt;2&lt;/sub&gt;&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;00&lt;sub&gt;2&lt;/sub&gt;&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;0&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;1&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;01&lt;sub&gt;2&lt;/sub&gt;&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;01&lt;sub&gt;2&lt;/sub&gt;&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;1&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;0&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;01&lt;sub&gt;2&lt;/sub&gt;&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;00&lt;sub&gt;2&lt;/sub&gt;&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;1&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;1&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;10&lt;sub&gt;2&lt;/sub&gt;&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;01&lt;sub&gt;2&lt;/sub&gt;&lt;/th&gt;
  &lt;/tr&gt;
&lt;/table&gt;
&lt;/center&gt;

&lt;p&gt;Here is an example demonstrating the procedure for adding two binary numbers,&lt;/p&gt;

\[\left[ 0110 \right]_2 + \left[ 1101 \right]_2 = 
\begin{matrix}
  \begin{array}{r}
    &amp;amp; 0 &amp;amp; 1 &amp;amp; 1 &amp;amp; 0\\
   + &amp;amp; 1 &amp;amp; 1 &amp;amp; 0 &amp;amp; 1\\
    \hline
    1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 1 &amp;amp; 1
  \end{array}
\end{matrix} = \left[ 10011 \right]_2\]

\[\left[ 6 \right]_{10} + \left[ 13 \right]_{10} = \left[ 19 \right]_{10}\]

&lt;p&gt;&lt;strong&gt;Binary Multiplication&lt;/strong&gt; can be carried out with the knowledge of the above truth table. Multipliation of two $n$ bit binary numbers $A$ and $B$ can result in a binary number $C = A \times B$ with at most $2n$ binary bits.&lt;/p&gt;

\[\left[ 0110 \right]_2 \times \left[ 1101 \right]_2 = 
\begin{matrix}
  \begin{array}{r}
    &amp;amp; &amp;amp; &amp;amp; 0 &amp;amp; 1 &amp;amp; 1 &amp;amp; 0\\
    &amp;amp; &amp;amp; \times &amp;amp; 1 &amp;amp; 1 &amp;amp; 0 &amp;amp; 1\\
    \hline
    &amp;amp; &amp;amp; &amp;amp; 0 &amp;amp; 1 &amp;amp; 1 &amp;amp; 0\\
    &amp;amp; &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0\\
    &amp;amp; 0 &amp;amp; 1 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0\\
    0 &amp;amp; 1 &amp;amp; 1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0 &amp;amp; 0\\
    \hline
    1 &amp;amp; 0 &amp;amp; 0 &amp;amp; 1 &amp;amp; 1 &amp;amp; 1 &amp;amp; 0\\
  \end{array}
\end{matrix} = \left[ 1001110 \right]_2\]

\[\left[ 6 \right]_{10} + \left[ 13 \right]_{10} = \left[ 78 \right]_{10}\]

&lt;h3 id=&quot;numbers-represented-using-a-finite-number-of-bits-behave-like-modulo-n-numbers&quot;&gt;Numbers represented using a finite number of bits behave like modulo-$n$ numbers&lt;/h3&gt;
&lt;p&gt;Numbers represented in computer use a finite number of bits. For example, a 64 bit microprocessor uses 64 bits to represent data, which means that with a single word (64 bits) we can only represent upto a $2^{64}$ different numbers or data types. If we were representing whole numbers then, the maximum number that can be represented is $2^{64} - 1$. Arthimetic operations performed with 64 bit numbers are also restrcited to be 64 bit numbers. This results in these numbers behaving differently under arthimetic operations, compared to numbers with no such restriction on the number of bit. For example, 3-bit numbers under the operation of addition and multiplication will behave like modulo-$2^{3}$ numbers; overflows are ignored and the lower three bits are considered the results of the arthimethic operations.&lt;/p&gt;

&lt;p&gt;In general, whole numbers can be represented as discrete, equi-distant points on a number line (infinitely long) as shown in the following figure,&lt;/p&gt;
&lt;center&gt;
  &lt;img src=&quot;/figs/nl-wn.png&quot; width=&quot;50%&quot; height=&quot;50%&quot; /&gt;
&lt;/center&gt;

&lt;p&gt;While, the whole numbers represented with a finite number of bits can be represented on a circle (number-wheel) as the following figure,&lt;/p&gt;
&lt;center&gt;
  &lt;img src=&quot;/figs/nw-wn.png&quot; width=&quot;42%&quot; height=&quot;42%&quot; /&gt;
&lt;/center&gt;

&lt;h3 id=&quot;integers&quot;&gt;Integers&lt;/h3&gt;
&lt;p&gt;When representing negative numbers, on paper, one could simply use the ‘-‘ symbol, e.g. -51 in binary can be written as -110011. Since 0s and 1s are the only available symbols when representing things on a computer, we need a different approach to represent negative numbers: &lt;em&gt;2’s complement representation&lt;/em&gt;. Let’s assume that we working with 3 bit numbers; we can represent upto 8 different numbers. In the 2’s complement representation, the binary representation of positive numbers and zero remain unchanged. However, when we have a negative number $N$, we first take the binary representation of $\vert N \vert$, invert the bits, and add 1 to the inverted numbers.&lt;/p&gt;

\[-2 \xrightarrow[\text{binary}]{\text{2 in}} 010 \xrightarrow[\text{bits}]{\text{Invert}} 101 \xrightarrow[\text{1}]{\text{Add}} 110\]

&lt;p&gt;In the 2’s complement representation, the most significant bit represents the sign bit, and it is 1 for negative numbers. As the following table indicates.&lt;/p&gt;

&lt;center&gt;
&lt;table class=&quot;tg&quot;&gt;
  &lt;tr&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;Binary No.&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;Whole number&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;Integer&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;000&lt;sub&gt;2&lt;/sub&gt;&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;0&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;0&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;001&lt;sub&gt;2&lt;/sub&gt;&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;1&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;1&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;010&lt;sub&gt;2&lt;/sub&gt;&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;2&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;2&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;011&lt;sub&gt;2&lt;/sub&gt;&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;3&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;3&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;100&lt;sub&gt;2&lt;/sub&gt;&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;4&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;-4&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;101&lt;sub&gt;2&lt;/sub&gt;&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;5&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;-3&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;110&lt;sub&gt;2&lt;/sub&gt;&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;6&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;-2&lt;/th&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;111&lt;sub&gt;2&lt;/sub&gt;&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;7&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;-1&lt;/th&gt;
  &lt;/tr&gt;
&lt;/table&gt;
&lt;/center&gt;

&lt;p&gt;We can convert a 2’s complement number to the corresponding decimal number using the following formula,&lt;/p&gt;

\[N = -b_{n-1}2^{n-1} + \sum_{i=0}^{n-2} b_i2^i\]

&lt;p&gt;The followiing image shows another way to look at 2’s complement numbers.&lt;/p&gt;
&lt;center&gt;
  &lt;img src=&quot;/figs/nw-int.png&quot; width=&quot;42%&quot; height=&quot;42%&quot; /&gt;
&lt;/center&gt;

&lt;center&gt;
&lt;div class=&quot;textbox&quot;&gt;
&lt;b&gt;Prove:&lt;/b&gt; &lt;i&gt;In the 2&apos;s complement representation using $n$-bits, (a) the highest positive integer that can be represented is $2^{n-1} - 1$; and (b) the lowest negative integer that can be represented is $-2^{n-1}$.&lt;/i&gt; 
&lt;/div&gt;  
&lt;/center&gt;

&lt;p&gt;&lt;strong&gt;Binary Addition&lt;/strong&gt;. The truth table for addition remains the same, and we can add two numbers like we did with whole numbers. This handles the addition of both negative and positive numbers, but we need to be careful when interpreting the results because of the sign bit. Addition of numbers corresponds to clockwise movement along the number-wheel, and the 2’s complement representation is such that addition by positive numbers can be seen as clockwise movements, and that of negative numbers as anti-clockwise movement.&lt;/p&gt;

&lt;p&gt;However, we need to keep in mind the following conditions, which indicate an overflow:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;Addition of two positive numbers cannot result in a negative number, e.g. \(3 + 2 = [011]_2 + [010]_2 = [101]_2\).&lt;/li&gt;
  &lt;li&gt;Addition of two negative numbers cannot result in a positive number, e.g. \(-3 + -4 = [101]_2 + [100]_2 = [001]_2\). Note that the addition of negative numbers in 2’s complement number will result a four bit number. Here we simply ignore the fourth bit.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When adding a positive and negative 2’s complement number, we never run into trouble.&lt;/p&gt;

&lt;p&gt;It should be noted that overflow here does not mean the presence of a carryover bit in the \((n+1)^{th}\) position, but rather when the boundary on the number-wheel between extreme positive and negative numbers is crossed by the addition or multiplication operation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Binary Multiplication&lt;/strong&gt;. We can multiply 2’s complement numbers like we do with binary whole numbers. The products come out with the appropriate signs provided there is no overflow. Consider wo binary signed numbers $B_1$ and $B_2$. An overflow occurs when: the product $\vert B_1 \times B_2$ is greater than $2^{n-1}$ when the $\text{sign}\left(B_1 \times B_2\right)$ is $-1$, or when the product $\vert B_1 \times B_2$ is greater than $2^{n-1} - 1$ when the $\text{sign}\left(B_1 \times B_2\right)$ is $+1$. There is no overflow when one of the numbers is $0$. You can verify this writing down the product table for 2 bit numbers.&lt;/p&gt;

&lt;p&gt;The second part of this blog-post will deal with fixed and floating point numbers.&lt;/p&gt;
</description>
				<pubDate>Sat, 28 Mar 2020 18:30:00 +0000</pubDate>
				<link>https://siva82kb.github.io/2020/03/representation-of-numbers-in-computers-1</link>
				<guid isPermaLink="true">https://siva82kb.github.io/2020/03/representation-of-numbers-in-computers-1</guid>
			</item>
		
			<item>
				<title>Understanding the Monty Hall Problem</title>
				<description>&lt;p&gt;s
I had come across the Monty Hall problem a year back, and my answer that could come up with the standard one - “I would not switch my choice”. In case you do not know what that means, let me start by describing the Monty Hall problem.&lt;/p&gt;

&lt;p&gt;The Monty Hall problem is a puzzle in probability. Assume that you are in a gameshow, where there are three doors (A, B, C) - one of the doors conceals a car, which you can win if you choose this door correctly; the other two doors have things that are not of any value. You are first required to choose a door. Following this the host checks the remaining doors, and opens of the on that does not contain the car. You are now given a chance to either stick with your original choice, or switch your choice to the remaining door. What would you be the better option? Stick with your original choice, or switch to the other door.&lt;/p&gt;

&lt;p&gt;We will first look at the standard wrong solution, and then look at the correct solution.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Standard Solution&lt;/strong&gt;: The probability of our first choice (e.g. A) being correct is \(\frac{1}{3}\). Then, when the host opens a door that does not contain the car (e.g. B). We are now left with two doors (A and C), and the probability of the car being behind either one of these doors is $\frac{1}{2}$. Thus, it would make no difference whether we switch or stick to our original choice.&lt;/p&gt;

&lt;p&gt;Lets look at this systematically and see if the above solution is correct. Because there are only three doors, we could easily enumerate all possiblities and see if it gives us an inight into this problem and the solution.&lt;/p&gt;

&lt;style type=&quot;text/css&quot;&gt;
.tg  {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;border-color:black;}
.tg .tg-baqh{text-align:center;vertical-align:top}
.tg .tg-c3ow{border-color:inherit;text-align:center;vertical-align:top}
.tg .tg-7btt{font-weight:bold;border-color:inherit;text-align:center;vertical-align:top}
&lt;/style&gt;

&lt;table class=&quot;tg&quot;&gt;
  &lt;tr&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;Car&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;Chosen&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;Revealed&lt;/th&gt;
    &lt;th class=&quot;tg-7btt&quot;&gt;Remaining&lt;/th&gt;
    &lt;th class=&quot;tg-baqh&quot;&gt;&lt;span style=&quot;font-weight:bold&quot;&gt;Switch?&lt;/span&gt;&lt;/th&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;A&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;A&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;B/C&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;C/B&lt;/td&gt;
    &lt;td class=&quot;tg-baqh&quot;&gt;No&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;A&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;B&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;C&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;A&lt;/td&gt;
    &lt;td class=&quot;tg-baqh&quot;&gt;Yes&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;A&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;C&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;B&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;A&lt;/td&gt;
    &lt;td class=&quot;tg-baqh&quot;&gt;Yes&lt;/td&gt;
  &lt;/tr&gt;

  &lt;tr&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;B&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;A&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;C&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;B&lt;/td&gt;
    &lt;td class=&quot;tg-baqh&quot;&gt;Yes&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;B&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;B&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;A/C&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;C/A&lt;/td&gt;
    &lt;td class=&quot;tg-baqh&quot;&gt;No&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;B&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;C&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;B&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;A&lt;/td&gt;
    &lt;td class=&quot;tg-baqh&quot;&gt;Yes&lt;/td&gt;
  &lt;/tr&gt;

  &lt;tr&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;C&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;A&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;B&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;C&lt;/td&gt;
    &lt;td class=&quot;tg-baqh&quot;&gt;Yes&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;C&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;B&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;A&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;C&lt;/td&gt;
    &lt;td class=&quot;tg-baqh&quot;&gt;No&lt;/td&gt;
  &lt;/tr&gt;
  &lt;tr&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;C&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;C&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;B&lt;/td&gt;
    &lt;td class=&quot;tg-c3ow&quot;&gt;A&lt;/td&gt;
    &lt;td class=&quot;tg-baqh&quot;&gt;Yes&lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;

&lt;p&gt;&lt;br /&gt;&lt;/p&gt;

&lt;p&gt;Looking at the last column, we see that, irrespective of the door containing the car and the our initial choice, swtiching would help us win $\frac{2}{3}$rd of the times. Our standard answer does not line-up with  systematic analysis.&lt;/p&gt;

&lt;p&gt;Let $A$ be the event of our first choice of door containing the car. Then, $P(A) = \frac{1}{3}$. After we select a door, the host chooses a door to reveal; the door revealed depends on our original choice as the host knows which door contains the car. Let $B$ represent the event that the door that remains contains the car. The probability of $B$ depends on $A$. If $A$ is true then $P(B \, \lvert \, A) = 0$; the door with the car has been selected so $B$ cannot be true. However, if $A$ is false, then $P(B \, \lvert \, A^c) = 1$; this is because the host will only reveal the door without the car. Using the theorem of total probability, we have&lt;/p&gt;

\[P(B) = P(B \, \lvert \, A)P(A) + P(B \, \lvert \, A^c)P(A^c) = 0 \cdot \frac{1}{3} + 1 \cdot \frac{2}{3} = \frac{2}{3}\]

&lt;p&gt;This number agrees with the results in the table above. So, where did we go wrong in the standard solution?&lt;/p&gt;

&lt;p&gt;The problem with the standard solution is that we ignore the fact that the host has knowledge of the door containing the car. This is implied in the statement “… We are now left with two doors (A and C), and the probability of the car being behind either one of these doors is $\frac{1}{2}$ …”. But this is false. The door that the host leave unopened is actually more likely to have the car as he will only open the door without the car. To see this more cearly, lets see what happens when the host randomly chooses a door to open and that this door does not contain the car. Then,  we have the following,&lt;/p&gt;

\[P(B \, \lvert \, A) = 0 \quad \text{and} \quad P(B \, \lvert \, A^c) = \frac{1}{2}\]

&lt;p&gt;Thus,&lt;/p&gt;

\[P(B) = P(B \, \lvert \, A)P(A) + P(B \, \lvert \, A^c)P(A^c) = 0 \cdot \frac{1}{3} + \frac{1}{2} \cdot \frac{2}{3} = \frac{1}{3}\]

&lt;p&gt;Here, we see that both $P(A)$ and $P(B)$ are equal and thus there would be no benefit in switching our choice.&lt;/p&gt;

&lt;p&gt;After I spent some time thinking about this simply problem and its solution, I realize that the problem with my original approach to the problem was really just lazy thinking.&lt;/p&gt;

&lt;p&gt;There are lots of such problems involving conditional probability that put you understanding on the nuances of probability theory to the test. I hope to write about these various problems in my later posts.&lt;/p&gt;
</description>
				<pubDate>Mon, 08 Jul 2019 03:31:00 +0000</pubDate>
				<link>https://siva82kb.github.io/2019/07/understanding-monty-hall-problem</link>
				<guid isPermaLink="true">https://siva82kb.github.io/2019/07/understanding-monty-hall-problem</guid>
			</item>
		
			<item>
				<title>Using Sinc Pulses to Characterize LTI Systems</title>
				<description>&lt;p&gt;I was involved in a discussion, a few months back, about a linear time-invariant (LTI) filter that someone was trying to characterize. Their plan was to use a sinc pulse as an input, and use the Fourier spectrum of the filter’s output as a direct readout of the filter’s frequency response.&lt;/p&gt;

&lt;p&gt;At first, it sounded like a strange idea but after some thought, it sounded reasonable. I had never thought about characterizing a filter using a sinc pulse before. I think my confusion was due to the fact that we often use impulse, step, and sinusoisal signals to characterize LTI systems, as these are easier to generate (or simulate) using analog hardware. I am not aware of an analog circuit that would generate an approximate sinc pulse.&lt;/p&gt;

&lt;p&gt;Consider a continuous-time LIT system $H$, with impulse response $h(t)$ and frequency response $H(j\omega)$, the input-output relationship is given by,&lt;/p&gt;

\[y(t) = H\left\{x(t)\right\} = h(t) * x(t) = \int_{-\infty}^{\infty} x(\tau)h(t - \tau)d\tau \quad \text{and} \quad Y(j\omega) = H(j\omega)X(j\omega)\]

&lt;p&gt;where, $x(t)$ is the input and $y(t)$ is the output of the system $H$.&lt;/p&gt;

&lt;p&gt;For an input sinc pulse $x(t) = \frac{\omega_c}{\pi}\text{sinc} \left(\omega_c t\right) = \frac{\omega_c}{\pi}\frac{\sin \left( \omega_c t \right)}{\omega_c t}$, the Fourier spectrum of the output is given by,&lt;/p&gt;

\[Y(j\omega) = H(j\omega)X(j\omega) = \begin{cases} H(j\omega) &amp;amp; \left| \omega \right| \leq \omega_c \\
0 &amp;amp; \left| \omega \right| &amp;gt; \omega_c \\
\end{cases}\]

&lt;p&gt;Here, the sinc function acts as an approximate impulse function; increasing $\omega_c$ provides a better and better approximation of the impulse fucntion.&lt;/p&gt;

\[\int_{-\infty}^{\infty} \frac{\omega_c}{\pi}\text{sinc} \left(\omega_c t\right)dt = 1 \quad \text{and} \quad \lim_{\omega_c \to \infty} \frac{\omega_c}{\pi}\text{sinc} \left(\omega_c t\right) = \delta(t)\]

&lt;p&gt;Simultaneously, the brickwall frequency response tends towards a contant function $\lim_{\omega_c \to \infty}X(j\omega) = 1$.&lt;/p&gt;

&lt;p&gt;Thus, if $H$ is a bandlimited filter $\left( H\left( j\omega \right) = 0, \forall \vert \omega \vert &amp;gt; \omega_H\right)$, then $Y\left(j\omega\right) = H\left(j\omega\right)$ when $\omega_c \geq \omega_H$.&lt;/p&gt;

&lt;p&gt;This means that the output of the system $H$ to two sinc inputs $x_1(t) = \frac{\omega_{c1}}{\pi}\text{sinc} \left(\omega_{c1} t\right)$ and $x_2(t) = \frac{\omega_{c2}}{\pi}\text{sinc} \left(\omega_{c2} t\right)$ will be the same, as long as $\omega_{c1} \geq \omega_H$ and $\omega_{c2} \geq \omega_H$. This implies that $x_1(t) - x_2(t)$ is in the &lt;em&gt;nullspace&lt;/em&gt; or the &lt;em&gt;kernel&lt;/em&gt; of the system $H$. The &lt;em&gt;nullspace&lt;/em&gt; of this system is the eigenspacce spanned by the set of eigenvectors \(\left\{e^{j\omega t}\right\}_{\forall \lvert \omega \rvert \geq \omega_H}\); it can be easily verified that $x_1(t) - x_2(t)$ is in \(\text{span}(\left\{e^{j\omega t}\right\}_{\forall \lvert \omega \rvert \geq \omega_H})\).&lt;/p&gt;

&lt;p&gt;For systems that are practically bandlimited limited, sufficiently narrow and tall sinc pulse is as good an impulse function for the purpose of characterizing the system.&lt;/p&gt;
</description>
				<pubDate>Tue, 25 Jun 2019 15:31:00 +0000</pubDate>
				<link>https://siva82kb.github.io/2019/06/using-sinc-pulses-to-characterize-lti-systems</link>
				<guid isPermaLink="true">https://siva82kb.github.io/2019/06/using-sinc-pulses-to-characterize-lti-systems</guid>
			</item>
		
			<item>
				<title>Least Square Estimation of AR Models and Whitening - Part I</title>
				<description>&lt;p&gt;Consider an $p$-order stationary autoregressive model driven by white noise.&lt;/p&gt;

\[x_n = \sum_{k=1}^{p} a_kx_{n-k} + \epsilon_n\]

&lt;p&gt;where, $\epsilon_n$ is Gaussian white noise with zero mean and variance $\sigma_{\epsilon}^2$.&lt;/p&gt;

&lt;p&gt;Let us assume that we have $N+$ sample of this AR process and we are interested in estimating the parameter $a_k$. We can arrange the data into a set of $M=N+1-p$ linear equations,&lt;/p&gt;

\[\begin{bmatrix}
x_{0} &amp;amp; x_{1} &amp;amp; \cdots &amp;amp; x_{p-1} \\
x_{1} &amp;amp; x_{2} &amp;amp; \cdots &amp;amp; x_{p} \\
x_{2} &amp;amp; x_{3} &amp;amp; \cdots &amp;amp; x_{p+1} \\
% x_{p+1} &amp;amp; x_{p} &amp;amp; \cdots &amp;amp; x_{2} \\
\vdots &amp;amp; \vdots &amp;amp; \ddots &amp;amp; \vdots \\
x_{N-p} &amp;amp; x_{N-p+1} &amp;amp; \cdots &amp;amp; x_{N-1}
\end{bmatrix} \begin{bmatrix}
a_p \\
a_{p-1} \\
\vdots \\
a_1
\end{bmatrix} = \begin{bmatrix}
x_{p}\\
x_{p+1}\\
x_{p+2}\\
\vdots\\
x_{N}
\end{bmatrix}\]

\[\begin{bmatrix}
\mathbf{x}_{N-p, M} &amp;amp; \mathbf{x}_{N-p+1, M} &amp;amp; \cdots &amp;amp; \mathbf{x}_{N-1, M}
\end{bmatrix} \mathbf{a} = \mathbf{x}_{N, M}\]

\[\mathbf{X}_{N, M}\mathbf{a} = \mathbf{x}_{N, M}\]

&lt;p&gt;where, \(\mathbf{x}_{k, M}\) is a column vector whose elements are the past \(M\) of \(x_n\) starting from the instant \(k\); \(x_{k-M+1}\), \(x_{k}\) are the first and last elements of the vector, respectively. \(\mathbf{X}_{N, M}\) consists of the columns \(\mathbf{x}_{N-p, M}, \,\mathbf{x}_{N-p+1, M}, \, \ldots \, , \mathbf{x}_{N-p, M}\).&lt;/p&gt;

&lt;p&gt;The least-squares estimate of $\mathbf{a}$ is given by,&lt;/p&gt;

\[\hat{\mathbf{a}} = \left(\mathbf{X}_{N, M}^T\mathbf{X}_{N, M}\right)^{-1}\mathbf{X}_{N, M}^T\mathbf{x}_{N, M}\]

&lt;p&gt;Post-multiplying \(\mathbf{x}_{N, M}\) by the pseudo-inverse will provide the least square estimate of \(\mathbf{a}\).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A simple example&lt;/strong&gt;: Let us start with the simplest possible example of a AR process where \(p=1\).&lt;/p&gt;

\[x_n = a_1 x_{n-1} + \epsilon_n\]

&lt;p&gt;Lets assume that we have \(N\) samples of \(x_n\), we can then estimate the parameter \(a_1\) using the following,&lt;/p&gt;

\[\hat{a}_1 = \frac{\mathbf{x}_{N-1, M}^T\mathbf{x}_{N, M}}{\mathbf{x}_{N, M}^T\mathbf{x}_{N, M}}\]

&lt;h3 id=&quot;running-estimate-of-a-ar-process-of-order-1&quot;&gt;Running estimate of a AR process of order 1&lt;/h3&gt;
&lt;p&gt;The following figure shows the result from an estimation procedure for a &lt;em&gt;autoregressive process&lt;/em&gt; of order 1. The code used for generate this plot can be found  &lt;a href=&quot;https://nbviewer.jupyter.org/github/siva82kb/siva82kb.github.io/blob/master/notebooks/2018-09-15-Least-Square-Estimation-of-AR-Models-And-Whitening-Part-I.ipynb&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;/figs/ar1.png&quot; width=&quot;75%&quot; height=&quot;75%&quot; /&gt;
&lt;/p&gt;

&lt;h3 id=&quot;running-estimate-of-a-ar-process-of-order-p&quot;&gt;Running estimate of a AR process of order ‘p’&lt;/h3&gt;
&lt;p&gt;The following figure shows the result from an estimation procedure for a &lt;em&gt;autoregressive process&lt;/em&gt; of order 3. The code used for generate this plot can be found  &lt;a href=&quot;https://nbviewer.jupyter.org/github/siva82kb/siva82kb.github.io/blob/master/notebooks/2018-09-15-Least-Square-Estimation-of-AR-Models-And-Whitening-Part-I.ipynb&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p align=&quot;center&quot;&gt;
&lt;img src=&quot;/figs/ar3.png&quot; width=&quot;75%&quot; height=&quot;75%&quot; /&gt;
&lt;/p&gt;

&lt;h3 id=&quot;whitening-using-estimated-ar-parametes-lefthataright&quot;&gt;Whitening using estimated AR parametes \(\left(\hat{a}\right)\)&lt;/h3&gt;

&lt;p&gt;Once \(\hat{a}\) is obtained, then the signal \(y_n\) can be whitened by passing it through the following moving average filter.&lt;/p&gt;

\[w_n = y_n - \sum_{k=1}^{p} \hat{a}_ky_{n-k}\]

&lt;p&gt;\(w_n\) would be the out of this moving average filter, and $w_n$ will be a white noise. The input to this moving average filter the measured time series \(y_n\).&lt;/p&gt;
</description>
				<pubDate>Sat, 15 Sep 2018 10:55:06 +0000</pubDate>
				<link>https://siva82kb.github.io/2018/09/least-square-estimation-of-ar-models-and-whitening-part-i</link>
				<guid isPermaLink="true">https://siva82kb.github.io/2018/09/least-square-estimation-of-ar-models-and-whitening-part-i</guid>
			</item>
		
			<item>
				<title>Input-Output Relationship of a Linear Time-Varying System</title>
				<description>&lt;p&gt;Most of us that have studied signal processing or control theory would be familiar with the input-output relationship of linear time-invariant (LTI) systems. If $H$ is an LTI system with impulse response $h(t)$, then the output of the system for any arbitrary input is given by &lt;strong&gt;convolution integral&lt;/strong&gt;,&lt;/p&gt;

\[y(t) = \int_{-\infty}^{\infty} h(\tau) x(t - \tau) d\tau \,, \quad t \in \mathbb{R}\]

&lt;p&gt;The same idea can be applied to a discrete-time system with impulse response $h[n]$. The output in this case is given by the &lt;strong&gt;convolution sum&lt;/strong&gt;,&lt;/p&gt;

\[y[n] = \sum_{k=-\infty}^{\infty}h[k]x[n - k] \,, \quad n \in \mathbb{Z}\]

&lt;p&gt;The fact that input-output (IO) relationships for LIT systems can be determined through convolution, also leads to popular transform-based representation, analysis and design of LIT systems.&lt;/p&gt;

&lt;p&gt;Linear-time varying (LTV) systems on the other hand cannot be understood through the convolution integral or the sum as shown above. The behavior of a LTV system depends explicity on time, and its IO behavior changes with time. If $H$ is a LTV system, then if \(H\left\{ x(t) \right\} = y(t)\), then \(H\left\{x(t - t_0)\right\} \neq y(t - t_0)\), i.e. time-shifted inputs do not produce time-shifted outputs.&lt;/p&gt;

&lt;p&gt;A LTV system can be viewed as a system with impulse response that is  time dependent, i.e. the output of the system to an impulse input $\delta(t - s)$ depends on both $t$ and $s$.&lt;/p&gt;

\[\phi(t, s) = H\left\{ \delta(t - s) \right\}, \quad t, s \in \mathbb{R}\]

&lt;p&gt;where, $t$ is time, and $s$ is the time instant at which the impulse is applied. In the case of an LTI system, the response to $\delta(t - s)$ is $h(t - s)$; the output only depends on a single argument $t - s$.&lt;/p&gt;

&lt;p&gt;In LTI systems, $h(t)$ acts as a weighting function that determines how the past, present and future input values are combined to produce the present output; this is the operation performed by the covolution operation. $\phi(t, s)$ also plays a similar role. The output at a given time $t$ for an LTV system, will weight the past, present and future values according to the function $\phi(t, s)$. In order to find out the output of an LTV system for an arbitrary input $x(t)$, lets start with the following,&lt;/p&gt;

\[x(t) = \int_{-\infty}^{\infty} x(\tau) \delta(t - \tau) d\tau\]

&lt;p&gt;The output of the system $H$ to the input $\delta(t - \tau)$ is given by $h(\tau, t)$. Thus, $y(t)$ can be obtained as the following,&lt;/p&gt;

\[y(t) = H\left\{ \int_{-\infty}^{\infty} x(\tau) \delta(t - \tau) d\tau \right\} = \int_{-\infty}^{\infty} x(\tau) H\left\{ \delta(t - \tau) \right\}d\tau\]

\[y(t) = \int_{-\infty}^{\infty} x(\tau) h(\tau, t) d\tau\]

&lt;p&gt;In the above equation the input at time $\tau$ is weighted by the factor $h(\tau, t)$ to determine the output of the system at time $t$.&lt;/p&gt;

\[\phi(\tau, t) \longrightarrow \begin{cases}
\text{Weight for past input} &amp;amp; \tau &amp;lt; t \\
\text{Weight for the present input} &amp;amp; \tau = t \\
\text{Weight for the future input} &amp;amp; \tau &amp;gt; t \\
\end{cases}\]

&lt;p&gt;In the case of a causal LTV system, we have $h(\tau, t) = 0$ for $\tau &amp;gt; t$.&lt;/p&gt;

&lt;p&gt;In the case of a discrete-time LTV system, we could express the IO relatioship similarly,&lt;/p&gt;

\[y[n] = \sum_{k=-\infty}^{\infty} x[k] h[k, n]\]

&lt;p&gt;where, $h[k, n]$ is the output of the LTV system to an impulse $\delta[n - k]$.&lt;/p&gt;
</description>
				<pubDate>Mon, 20 Aug 2018 13:00:00 +0000</pubDate>
				<link>https://siva82kb.github.io/2018/08/linear-time-variant-systems</link>
				<guid isPermaLink="true">https://siva82kb.github.io/2018/08/linear-time-variant-systems</guid>
			</item>
		
	</channel>
</rss>
