1245 lines
91 KiB
Plaintext
1245 lines
91 KiB
Plaintext
{
|
|
"cells": [
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"# Lecture 3. Projectors. Least squares problem. QR factorization."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"# Projectors"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"source": [
|
|
"* A projector is a square matrix $P$ which satisfies\n",
|
|
"$$\n",
|
|
"P^2=P\n",
|
|
"$$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"source": [
|
|
"* Lets inspect the geometric meaning of a projection\n",
|
|
"![](proj.png)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"source": [
|
|
"* For any vector $v$ in $\\mathrm{range}(P)$ one has $Pv=v$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"source": [
|
|
"* For $S_1 = \\mathrm{range}(P)$ and $S_2=\\mathrm{null}(P)$ it is said that $P$ projects onto $S_1$ along $S_2$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"## Orthogonal projectors\n",
|
|
"* For orthogonal projector: $S_1\\perp S_2$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"source": [
|
|
"* One can show (homework) that this is equivalent to $P = P^T$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"source": [
|
|
"- Lets inspect the geometric meaning of an orthogonal projection\n",
|
|
"![](projorth.png)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"## Projection with orthonormal basis\n",
|
|
"* Let us consider orthogonal projection onto certain $S_1$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"source": [
|
|
"* Let dimension of $S_1$ be $n$; $q_1,q_2,...,q_n$ form an orthonormal basis for $S_1$ and $q_{n+1},...,q_m$ form an orthonormal basis for $S_2$."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"source": [
|
|
"* Consider \n",
|
|
"$$\n",
|
|
"Q = \\bigg[q_1\\bigg|q_2\\bigg|...\\bigg|q_n\\bigg|q_{n+1}\\bigg|...\\bigg|q_m\\bigg]\n",
|
|
"$$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"source": [
|
|
"* Then:\n",
|
|
"$$\n",
|
|
"PQ = \\bigg[q_1\\bigg|q_2\\bigg|...\\bigg|q_n\\bigg|0\\bigg|...\\bigg|0\\bigg]\n",
|
|
"$$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"source": [
|
|
" * We thus have $Q^TPQ =\\mathrm{diag}(1,1,...,1,0,0,0)=\\Sigma$\n",
|
|
"which provides SVD decomposition ot $P$: \n",
|
|
"\n",
|
|
"$$P = Q\\Sigma Q^T$$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"source": [
|
|
"* Reduced SVD of a projector $P$ reads:\n",
|
|
"$$\n",
|
|
"P = \\hat Q \\hat Q^T\n",
|
|
"$$\n",
|
|
"where $\\hat Q$ is not orthogonal matrix (as it is not square), but it has orthonormal columns."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"## Projection with an arbitrary basis \n",
|
|
"* Suppose that we want to project on a space spanned by columns of arbitrary $A$ (they are not necessarily orthonormal, but assumed to be linearly independent)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"source": [
|
|
"* In passing from $v$ to its orthogonal projection $y \\in \\mathrm{range}(A)$, the difference $y-v$ must be orthogonal to $\\mathrm{range}(A)$:\n",
|
|
"$A^T (Ax-v) = 0$, indeed:"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"![](projorth2.png)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"source": [
|
|
"* If the columns of $A$ are linearly independent:\n",
|
|
"$$\n",
|
|
"x = (A^T A)^{-1}A^T v\n",
|
|
"$$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"source": [
|
|
"* The projection is thus given by the operator\n",
|
|
"$$\n",
|
|
"P = A(A^T A)^{-1}A^T\n",
|
|
"$$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"# Linear systems\n",
|
|
"\n",
|
|
"- Linear systems appear as:\n",
|
|
"\n",
|
|
" - Linear regression problems\n",
|
|
" - Discretization of partial differential/integral equations\n",
|
|
" - At elementary steps of iterative optimization techniques"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"## Linear equations and matrices\n",
|
|
"A linear system of equations can be written in the form\n",
|
|
"\n",
|
|
"\\begin{align*}\n",
|
|
" &2 x + 3 y = 5\\quad &\\longrightarrow \\quad &2x + 3 y + 0 z = 5\\\\\n",
|
|
" &3 x + 2z = 4\\quad &\\longrightarrow\\quad &3 x + 0 y + 2 z = 4\\\\\n",
|
|
" &x + y = 2\\quad &\\longrightarrow\\quad & 1 x + 1 y + 0 z = 2\\\\\n",
|
|
"\\end{align*}"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"## Matrix form\n",
|
|
"\n",
|
|
"$$\n",
|
|
"\\begin{pmatrix}\n",
|
|
"2 & 3 & 0 \\\\\n",
|
|
"3 & 0 & 2 \\\\\n",
|
|
"1 & 1 & 0 \\\\\n",
|
|
"\\end{pmatrix}\\begin{pmatrix}\n",
|
|
"x \\\\\n",
|
|
"y \\\\\n",
|
|
"z \n",
|
|
"\\end{pmatrix} = \n",
|
|
"\\begin{pmatrix}\n",
|
|
"5 \\\\\n",
|
|
"4 \\\\\n",
|
|
"2\n",
|
|
"\\end{pmatrix}\n",
|
|
"$$\n",
|
|
"\n",
|
|
"or simply\n",
|
|
"\n",
|
|
"$$ A u = b $$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"## Over/under determined linear systems\n",
|
|
"\n",
|
|
"If the system $Ax = b$ has\n",
|
|
"\n",
|
|
"- more equations than unknowns, it is called overdetermined system (typically no solution)\n",
|
|
"\n",
|
|
"- less equations than unknowns, it is called underdetermined system (typically many solutions)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"## Overdetermined linear systems\n",
|
|
"\n",
|
|
"- The number of equations is > than the number of unknowns. \n",
|
|
"\n",
|
|
"- The simplest example is linear fitting, fitting a set of 2D points by a line.\n",
|
|
"\n",
|
|
"- Then, a typical way is to minimize the residual (least squares)\n",
|
|
"\n",
|
|
"$$\\Vert A x - b \\Vert_2 \\rightarrow \\min$$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"source": [
|
|
"## Underdetermined linear systems\n",
|
|
"\n",
|
|
"- The number of equations is > than the number of unknowns. \n",
|
|
"\n",
|
|
"- In this case, there could be infinitely many solutions $x$\n",
|
|
"\n",
|
|
"- Typical problem in Machine Learning: employ some kind of regularization. For example, one may find the solution to $Ax=b$ with a minimal norm \n",
|
|
"$$\\Vert x \\Vert_2\\to\\min$$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"## Example of least squares\n",
|
|
"Consider a two-dimensional example. Suppose we have a linear model \n",
|
|
"\n",
|
|
"$$y = ax + b$$\n",
|
|
"\n",
|
|
"and noisy data $(x_1, y_1), \\dots (x_n, y_n)$. Then the linear system on coefficients will look as follows\n",
|
|
"\n",
|
|
"$$\n",
|
|
"\\begin{split}\n",
|
|
"a x_1 &+ b &= y_1 \\\\\n",
|
|
"&\\vdots \\\\\n",
|
|
"a x_n &+ b &= y_n \\\\\n",
|
|
"\\end{split}\n",
|
|
"$$\n",
|
|
"\n",
|
|
"or in a matrix form\n",
|
|
"\n",
|
|
"$$\n",
|
|
"\\begin{pmatrix}\n",
|
|
"x_1 & 1 \\\\\n",
|
|
"\\vdots & \\vdots \\\\\n",
|
|
"x_n & 1 \\\\\n",
|
|
"\\end{pmatrix}\n",
|
|
"\\begin{pmatrix}\n",
|
|
"a \\\\\n",
|
|
"b\n",
|
|
"\\end{pmatrix} =\n",
|
|
"\\begin{pmatrix}\n",
|
|
"y_1 \\\\\n",
|
|
"\\vdots \\\\\n",
|
|
"y_n \\\\\n",
|
|
"\\end{pmatrix},\n",
|
|
"$$\n",
|
|
"\n",
|
|
"which represents overdetermined system."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"## Solving the least squares\n",
|
|
"- Suppose we need to solve\n",
|
|
"\n",
|
|
"$$ \\Vert A x - b \\Vert_2 \\rightarrow \\min_x, $$\n",
|
|
"\n",
|
|
"where $A$ is $m \\times n$, $m \\geq n$."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"![](projorth3.png)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"source": [
|
|
"- The residual $r = A x - b$ should be orthogonal to $\\mathrm{range} A$, and\n",
|
|
"or equivalently:\n",
|
|
"$$\n",
|
|
"P b = A x,\n",
|
|
"$$\n",
|
|
"where $P$ is a projector onto the range of $A$, that is $P = A(A^T A)^{-1}A^T$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"source": [
|
|
"- If $A$ is of a full rank, then \n",
|
|
"$$\n",
|
|
"x = (A^T A)^{-1} A^T b\n",
|
|
"$$\n",
|
|
"- The matrix $(A^T A)^{-1} A^T$ is known as a pseudoinverse, denoted as $A^+$. Can be easily computed in numpy."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"<matplotlib.legend.Legend at 0x1fdc8b5e340>"
|
|
]
|
|
},
|
|
"execution_count": 1,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
},
|
|
{
|
|
"data": {
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAAD6CAYAAAC4RRw1AAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAeNUlEQVR4nO3deXRV5b3/8feTEEhEMCjRC4kY2qvMQjBoLIJCvCAiELE4FH6KWnAoUkVTiBN4V2/hGqBqFf1ZxwqoVREQkaACalVQQpBUIQoImkEJ0SBDICE8948TQgKZzpQz7M9rra5lNufs8+1RPjw8+7u/21hrERGR0BMR6AJERMQzCnARkRClABcRCVEKcBGREKUAFxEJUQpwEZEQ1WiAG2OeM8bsMsb8u8axTGPMFmPMJmPMm8aYWL9WKSIiJzCN9YEbYwYC+4B/WGt7Vh0bAqyy1h42xvwvgLV2amMf1r59e5uYmOh10SIiTpKdnb3bWht3/PEWjb3RWvuhMSbxuGMra/y4FvhtU4pITExk/fr1TXmpi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TJjApEmTABg/fjyvv/569TmO/s1h3759pKam0rdvX3r16sWSJUsA1x8g3bp14/bbb6dv3758//33ZGZm0q9fP84991ymT58OwP79+xk+fDi9e/emZ8+eemqQhIW0pHg+njaYb2cNr/0ghaJN8EwqrLwPOg+EP6yDC24JufCGYFuBvzMNfsj17Tn/oxcMm+X22yZOnMhTTz3F2Wefzbp167j99ttZtWoVF110EWvXrsUYwzPPPMPDDz/MnDlzmD17Nk888QT9+/dn3759REdHM2vWLGbPns2yZctOOP/VV1/NRRddxEcffURqairjxo0jKSmJoqIipk+fTnZ2NqeccgqDBg0iKSmpwVqjo6N58803adu2Lbt37yYlJYWRI0cCkJeXx/PPP8+8efNYuXIl33zzDZ999hnWWkaOHMmHH35IcXExHTt25O233wZgz549bn9fIkEvRFoD3RFcAR4k9u3bxyeffMKYMWOqjx06dAiA/Px8rrnmGoqKiigvL6dz584A9O/fnylTpjB27FhGjx5NQkLDzf4JCQnk5eWxatUqVq1aRWpqKq+99hp79+7lkksuIS4uDoBrrrmGr7/+usFzWWu59957+fDDD4mIiKCgoKD6bwZnnXUWKSkpAKxcuZKVK1dW/4Gwb98+vvnmGwYMGMA999zD1KlTueKKKxgwILivvIu4LYRaA90RXAHuwUrZH44cOUJsbCwbN2484dfuuOMOpkyZwsiRI1mzZk31uNlp06YxfPhwli9fTkpKCu+9916jn9OqVSuGDRvGsGHDOOOMM1i8eDGpqamYelYELVq04MiRI4ArtMvLywHX8zyLi4vJzs4mKiqKxMTE6gdU1NxXt9aSkZHBLbfccsK5s7OzWb58ORkZGQwZMoQHH3yw0fpFgl4Itga6Q3vgdWjbti2dO3fmtddeA1zB98UXXwCu7YWjD2t48cUXq9+zbds2evXqxdSpU0lOTmbLli20adOm3senbdiwgcLCQsD1B8amTZs466yzuOCCC1izZg0lJSVUVFRU1wCQmJhIdnY2AEuWLKGioqK6ptNPP52oqChWr17Nzp076/zMoUOH8txzz7Fv3z4ACgoK2LVrF4WFhZx00kmMGzeOe+65hw0bNnj83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LwNcVqD0B/4fkGuM2Vh1zG8DxCQk3QEsqFrsbAduDHA9AWGtXWeMeR3YgKt7K4cwvCNTd2KKiISoUNhCERGROijARURClAJcRCREKcBFREKUAlxEJEQpwEVEQpQCXEQkRCnARURC1P8BbEBDC903/1IAAAAASUVORK5CYII=",
|
|
"text/plain": [
|
|
"<Figure size 432x288 with 1 Axes>"
|
|
]
|
|
},
|
|
"metadata": {
|
|
"needs_background": "light"
|
|
},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"%matplotlib inline\n",
|
|
"import numpy as np\n",
|
|
"import matplotlib.pyplot as plt\n",
|
|
"\n",
|
|
"a0 = 1; b0 = 2; n = 10\n",
|
|
"\n",
|
|
"xi = np.arange(n)\n",
|
|
"yi = a0 * xi + b0 + np.random.random(n)\n",
|
|
"A = np.hstack([xi[:,None], np.ones(n)[:,None]])\n",
|
|
"coef = np.linalg.pinv(A) @ yi\n",
|
|
"\n",
|
|
"plt.plot(xi, yi, 'o', label='$(x_i, y_i)$')\n",
|
|
"plt.plot(xi, coef[0]*xi + coef[1], label='Least Squares')\n",
|
|
"plt.legend(loc='best')"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"## What happens inside pinv?\n",
|
|
"We dont know yet -- computing pseudoinverse might be tough. Let us inspect a computationally cheaper way."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"## Solving the linear least squares via $QR$ decomposition.\n",
|
|
"\n",
|
|
"- Any matrix can be factored into a product \n",
|
|
"$$ A = Q R$$\n",
|
|
"where $Q$ is unitary, and $R$ is upper triangular.\n",
|
|
"- Finding optimal $x$ is equivalent to solving\n",
|
|
"$$\n",
|
|
"A^T A x = A^T b\n",
|
|
"$$\n",
|
|
"If $A$ is of full rank, it is the same as\n",
|
|
"$$ Rx = Q^T b. $$\n",
|
|
"- Since $R$ is upper triangular, the solving of this linear system costs $\\mathcal{O}(n^2)$. \n",
|
|
"- It is more stable than solving the normal equations"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"$$R^T Q^T Q R x = R^T Q^T b$$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"$$R x = Q^T b$$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"# QR decomposition\n",
|
|
"\n",
|
|
"- The name implies that a matrix is represented as a product \n",
|
|
"$$\n",
|
|
" A = Q R, \n",
|
|
"$$\n",
|
|
"where $Q$ is a column orthonormal matrix and $R$ is upper triangular. "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"source": [
|
|
"- The matrix sizes: $Q$ is $m \\times n$, $R$ is $n \\times n$ if $m\\geq n$."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"source": [
|
|
"- QR decomposition is defined for any rectangular matrix."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"source": [
|
|
"- QR decomposition can be computed in a $O(mn^2)$ (for $m>n$) (via so called direct methods)."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"## Full QR vs reduced QR\n",
|
|
"![](full.png)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"## QR decomposition: applications\n",
|
|
"\n",
|
|
"This decomposition plays a crucial role in many problems:\n",
|
|
"- Computing orthonormal bases in a linear space"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"source": [
|
|
"- Solving overdetermined systems of linear equations"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"source": [
|
|
"- QR-algorithm for the computation of eigenvectors and eigenvalues ([one of the 10 most important algorithms of the 20th century](https://archive.siam.org/pdf/news/637.pdf)) is based on the QR decomposition"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"## Existence of QR decomposition\n",
|
|
"Every rectangular $m \\times n$ matrix has a QR decomposition. \n",
|
|
"\n",
|
|
"\n",
|
|
"There are several ways to prove it and compute it:\n",
|
|
"\n",
|
|
"- Geometrical: using the Gram-Schmidt orthogonalization\n",
|
|
"- Practical: using Householder/Givens transformations "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"## Gram-Schmidt orthogonalization\n",
|
|
"\n",
|
|
"- QR decomposition is a mathematical way of writing down the Gram-Schmidt orthogonalization process. \n",
|
|
"- Given a sequence of vectors $a_1, \\ldots, a_m$ we want to find orthogonal basis $q_1, \\ldots, q_m$ such that every $a_i$ is a linear combination of such vectors. "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"source": [
|
|
"Gram-Schmidt:\n",
|
|
"- $q_1 := a_1/\\Vert a_1\\Vert$\n",
|
|
"- $q_2 := a_2 - (a_2, q_1) q_1, \\quad q_2 := q_2/\\Vert q_2 \\Vert$\n",
|
|
"- $q_3 := a_3 - (a_3, q_1) q_1 - (a_3, q_2) q_2, \\quad q_3 := q_3/\\Vert q_3 \\Vert$\n",
|
|
"\n",
|
|
"And so on.\n",
|
|
"\n",
|
|
"Note that the transformation from $Q$ to $A$ has triangular structure, since from the $k$-th vector we subtract only the previous ones. It follows from the fact that the product of triangular matrices is a triangular matrix."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"## QR decomposition: the practical way\n",
|
|
"\n",
|
|
"* Gram-Schmidt orthogonalization is not very practical as just described for numerical issues (will see later). One typically does it differently: Householder rotations (implemented in numpy)."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"## More on Pseudoinverse\n",
|
|
"Recall that we introduced pseudoinverse as\n",
|
|
"$$\n",
|
|
"A^+ = (A^T A)^{-1} A^T\n",
|
|
"$$\n",
|
|
"- Matrix $A^T A$ can be singular in general case.\n",
|
|
"- Therefore, we need to introduce the concept of pseudoinverse matrix $A^{\\dagger}$.\n",
|
|
"- The matrix $$A^{\\dagger} = \\lim_{\\alpha \\rightarrow 0}(\\alpha I + A^T A)^{-1} A^T$$ is called Moore-Penrose pseudoinverse of the matrix $A$."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"## Pseudoinverse and linear systems\n",
|
|
"Consider a system of equations $Ax\\approx b$\n",
|
|
"- $\\forall x$, we have $\\left\\|Ax-b\\right\\|_{2}\\geq \\left\\|Az-b\\right\\|_{2}$, where \n",
|
|
"$z=A^{+}b$\n",
|
|
"- If $A x = b$ is satisfiable, the vector $z=A^{+}b$ is a solution, and satisfies $\\|z\\|_{2}\\leq \\|x\\|_{2}$ for all other solutions\n",
|
|
"\n",
|
|
"As a result, the solution to the linear least squares problem (including least norm solutions) can formally be written as\n",
|
|
"$$x = A^{\\dagger} b.$$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"## Simple cases\n",
|
|
"\n",
|
|
"- If matrix $A$ is squared and non-singular we get standard inverse of $A$:\n",
|
|
"$$A^{\\dagger} = \\lim_{\\alpha \\rightarrow 0}(\\alpha I + A^T A)^{-1} A^T = (A^T A)^{-1} A^T = A^{-1} (A^{T})^{-1} A^T = A^{-1}$$\n",
|
|
"- If matrix $A$ has full column rank, then $A^T A$ is non-singular and we get \n",
|
|
"$$A^{\\dagger} = \\lim_{\\alpha \\rightarrow 0}(\\alpha I + A^T A)^{-1} A^T = (A^T A)^{-1} A^T. $$\n",
|
|
"- Pseudoinverse is uniquely defined in all other cases, too! "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"## Least squares via SVD \n",
|
|
"Lets inspect SVD approach to over- and under- determined problems."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Consider solving $Ax \\approx b$ for $A$ of arbitrary shape and possibly not of a full rank (the system cen be under- or overdetermined).\n",
|
|
"\n",
|
|
"Let $A = U \\Sigma V^T$ be SVD decomposition of $A$, then we need to solve"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"$$\n",
|
|
"U\\Sigma V^T x \\approx b\n",
|
|
"$$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Since $U$ and $V$ are orthogonal, we can just switch to new variables, $\\bar x = V^T x$ and $\\bar b = U^T b$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"$$\n",
|
|
"\\Sigma \\bar x \\approx \\bar b\n",
|
|
"$$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"Up to now, its not important if the system is under- or overdetermined. Here it becomes important. Lets consider underdetermined case."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"$$\n",
|
|
"\\begin{pmatrix}\n",
|
|
"\\sigma_1 & 0 & 0\\\\\n",
|
|
"0 & \\sigma_2 & 0 \\\\\n",
|
|
"0 & 0 & 0 \\\\\n",
|
|
"\\end{pmatrix}\n",
|
|
"\\begin{pmatrix}\n",
|
|
"\\bar x_1 \\\\\n",
|
|
"\\bar x_2 \\\\\n",
|
|
"\\bar x_3\n",
|
|
"\\end{pmatrix} \\approx\n",
|
|
"\\begin{pmatrix}\n",
|
|
"\\bar b_1 \\\\\n",
|
|
"\\bar b_2 \\\\\n",
|
|
"\\bar b_3\n",
|
|
"\\end{pmatrix},\n",
|
|
"$$\n"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {},
|
|
"source": [
|
|
"$$\n",
|
|
"\\bar x_1 = \\bar b_1 / \\sigma_1, \\bar x_2 = \\bar b_2 / \\sigma_2, \\bar x_3 = 0\n",
|
|
"$$"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"# Example: Signal recovery "
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 1,
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"import numpy as np\n",
|
|
"import matplotlib.pyplot as plt\n",
|
|
"import pandas as pd"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 2,
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"with np.load('data.npz') as data:\n",
|
|
" A, C = data['A'], data[\"C\"]"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 3,
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"(25, 60)"
|
|
]
|
|
},
|
|
"execution_count": 3,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
},
|
|
{
|
|
"data": {
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAACsCAYAAABikvffAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAe4ElEQVR4nO2dW4xl11nn/9/e+9zq0l3d7W637TYxiSxBQIOBVsgo82Aug8JF4/AQiUggIyE1DyAFCTR4eMmAhJQHbg8gJM/EihEQFAkysUYIYgVGgReIEzwTByexsTt22+2+uLuqq+rUOWefvT8e6hiKXv+v65yu6tOzj/4/yequ1avWXmvttb+zff7fxdwdQgghmkd2tycghBDi9pABF0KIhiIDLoQQDUUGXAghGooMuBBCNBQZcCGEaCgHMuBm9kEz+7qZvWxmTxzWpIQQQuyP3a4fuJnlAL4B4D8DuADgiwA+4u7/FP1O2zrexf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sCbc57DPLhkZvcBwOTPy3d5PgfCzFrYNd5/7O5/PmleqDW6+zqA/4NdPWNR1vYBAP/FzM5j9+vKHzCzP8LirA/u/ubkz8sAPoPdr2kXZn37MW8D/kUAD5vZt5pZG8BPAnhmznOYB88AeHzy98cBfPYuzuVA2O6r9icAvOjuv73nnxq/RjM7OXnzhpn1APwQgK9hAdYGAO7+39z9jLs/hN1n7a/d/aewIOszs2UzW33n7wB+GMALWJD1TcPcA3nM7Eex+71cDuApd/+NuU7gkDGzTwF4FLsZ0C4B+BiA/wXg0wC+BcBrAD7s7jcLnY3AzP4TgL8F8BX82/eov4rd78EbvUYz+w/YFbly7L7MfNrdf93MTqDha7uZyVcov+zuP74o6zOzd2P3rRvY/Tr4T9z9NxZlfdOgSEwhhGgoisQUQoiGIgMuhBANRQZcCCEaigy4EEI0FBlwIYRoKDLgQgjRUGTAhRCiociACyFEQ/kXq61d/zGlqiEAAAAASUVORK5CYII=",
|
|
"text/plain": [
|
|
"<Figure size 432x288 with 1 Axes>"
|
|
]
|
|
},
|
|
"metadata": {
|
|
"needs_background": "light"
|
|
},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"plt.imshow(A)\n",
|
|
"A.shape"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"The image, stored in a matrix $A$ is obtained from a certain original $A_0$ via convolution with a filter $C$ addition of a noise. The filter $C$ 'blurs' the image, simultaneously changing the image size from $16\\times 51$ to $25\\times 60$."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 38,
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"def mat2vec(A):\n",
|
|
" return np.reshape(np.flipud(A), np.prod(A.shape))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 39,
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"def vec2mat(a, shape):\n",
|
|
" return np.flipud(np.reshape(a, shape))"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"source": [
|
|
"Representing the images as vectors, we can write down the filtering as follows:\n",
|
|
"$$\n",
|
|
"a_0\\to a = C a_0 + \\epsilon,\n",
|
|
"$$\n",
|
|
"where $\\epsilon$ is a noise vector (consisting from iid normal variables)."
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "markdown",
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"source": [
|
|
"Lets inspect how the filter $C$ acts on the images"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 40,
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAACJCAYAAAA8GMMgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAIW0lEQVR4nO3dT4xdZRnH8e/PtrRSSQShBCiKmsZIiNRkUklwwR+BqsTiwgQSky6M40ISTDSmsvFPQuLGPxtjUrWhiQIhaqUxRKhVgwujFK1SBKQhRZppOhA04gYFHhf3TJxAp9O5986c8t7vJ5mce945d94nz0x/PXnnnDOpKiRJb3xv6rsASdJ4GOiS1AgDXZIaYaBLUiMMdElqhIEuSY0YKdCTbE3yZJLDSXaMqyhJ0tJl2OvQk6wC/gZcBxwFHgZuqaq/LvSeM7K21rF+qPk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MNNDHaeL43MPO+u2sz3Xs+ySrGEQ5j+qqp92wxPXhzlV9U/gNwx+vzJJfbgS+FiSIwyWXq9J8kMmqwcAVNVMt50F9jBYml5yH/oI9IeBTUnemeQM4GZgbw91nC72Atu719uB+3qsZdllcCr+A+DxqvrmvE9NWh/O687MSfJm4EPAE0xQH6rqS1W1saouYZADv6qqTzJBPQBIsj7JWXOvgesZPMF2yX3o5caiJB9hsHa2CthVVXeseBE9WODJlT8D7gXeDvwd+ERVNfsn/5J8EPgt8Cj/Xze9ncE6+iT14X0MftG1isGJ1b1V9bUkb2OC+jCnW3L5QlXdOGk9SPIuBmflMFgGv6uq7himD94pKkmN8E5RSWqEgS5JjTDQJakRBrokNcJAl6RGGOiS1AgDXZIaYaBLUiP+B5iOd9fD+omsAAAAAElFTkSuQmCC",
|
|
"text/plain": [
|
|
"<Figure size 432x288 with 1 Axes>"
|
|
]
|
|
},
|
|
"metadata": {
|
|
"needs_background": "light"
|
|
},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"X = np.zeros((16,51))\n",
|
|
"X[5:15,15] = 1; X[5:15,30] = 1; X[5:15,40] = 1\n",
|
|
"X[5,10:20] = 1; X[5,30:41] = 1; X[15,30:41] = 1\n",
|
|
"plt.imshow(X);"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 41,
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXAAAACsCAYAAABikvffAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAN1klEQVR4nO3dbYwdV33H8d8vy+66fiDYSRysJCVJlRcgBI60SkHpC0MoSinC4UWkRGplJKTlBUhBCiIubw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i7iLg8Iq5U79/aTyLib9SR9tleZ3vD4ntJH5V0QB1p3zBaX8hj+2Pq3ZebkLQ7Ir7aagUaZvteSdvUewLaUUl3Svp3SfdJ+lNJL0q6OSKy3MDS9l9I+i9JT+rsfdQvqXcfPOs22n6feoNcE+p1Zu6LiL+3fZEyb9tSxS2UL0TEx7vSPttXq9frlnq3g78bEV/tSvuGwUpMAMgUKzEBIFMEOABkigAHgEwR4ACQKQIcADJFgANApghwAMgUAQ4Amfp/1Ut+qRi9fuUAAAAASUVORK5CYII=",
|
|
"text/plain": [
|
|
"<Figure size 432x288 with 1 Axes>"
|
|
]
|
|
},
|
|
"metadata": {
|
|
"needs_background": "light"
|
|
},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"x = mat2vec(X)\n",
|
|
"plt.imshow(vec2mat(C @ x, (25, 60)));"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 42,
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAACJCAYAAAA8GMMgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAYyElEQVR4nO2deXRc9XXHv3dGI2m02LK8IS94wTYGG28oZjEBO5glgQJpSQollLZJSFtSSEoOJWl70gbS5vScZulpQuKkHGgoS0jCEuKwhJ1ggu1gB+MN413W5kW7NJJmfv1D49aF+322JSOlT9/POT7S3J/uvN+77707z+/3nXsthAAhhBD//0kM9QSEEEKcGJTQhRAiJiihCyFETFBCF0KImKCELoQQMUEJXQghYsKAErqZXWpmW8xsm5ndfqImJYQQ4vix/urQzSwJYCuAiwDsBbAawLUhhI3MJ1lWGgoqK/3BHNlOERkAELrJ51E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bMlg7xdIaaJSGEfWY2DsAzZra5P28yFHfoewFMPuL1JAB+36zhQf3hYmf5nw1DPJ/3HTNLoS+Z/1cI4ad587CLw2FCCE0AXkDf+spwisMSAFeY2U70PXr9kJndh+EVAwBACGFf/mcDgEfQ92j6uOMwFAl9NYCZZjbNzAoBXAPg8SGYx+8KjwO4If/7DQAeG8K5vO9Y3634fwDYFEL4+hFDwy0OY/N35jCzNIDlADZjGMUhhPDFEMKkEMJU9OWB50IIn8AwigEAmFmpmZUf/h3AxeirYHvccRiSLxaZ2UfQ9+wsCeDuEMJXB30SQwCpXPkogB8BOBnAbgAfCyHEtuWfmZ0H4GUAb+J/n5t+CX3P0YdTHOahb6Erib4bqx+FEL5iZqMxjOJwmPwjly+EEC4fbjEws+nouysH+h6D3x9C+Gp/4qBvigohREzQN0WFECImKKELIURMUEIXQoiYoIQuhBAxQQldCCFighK6EELEBCV0IYSICUroQggRE/4bdYmDYkl2gyoAAAAASUVORK5CYII=",
|
|
"text/plain": [
|
|
"<Figure size 432x288 with 1 Axes>"
|
|
]
|
|
},
|
|
"metadata": {
|
|
"needs_background": "light"
|
|
},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"a = mat2vec(A)\n",
|
|
"a0 = np.linalg.pinv(C) @ a\n",
|
|
"A0 = vec2mat(a0, (16, 51))\n",
|
|
"plt.imshow(A0);"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 43,
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"outputs": [],
|
|
"source": [
|
|
"u, s, vh = np.linalg.svd(C, full_matrices=False)"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 44,
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"text/plain": [
|
|
"((1500, 816), (816,))"
|
|
]
|
|
},
|
|
"execution_count": 44,
|
|
"metadata": {},
|
|
"output_type": "execute_result"
|
|
}
|
|
],
|
|
"source": [
|
|
"C.shape, s.shape"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 45,
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAACJCAYAAAA8GMMgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAYyElEQVR4nO2deXRc9XXHv3dGI2m02LK8IS94wTYGG28oZjEBO5glgQJpSQollLZJSFtSSEoOJWl70gbS5vScZulpQuKkHGgoS0jCEuKwhJ1ggu1gB+MN413W5kW7NJJmfv1D49aF+322JSOlT9/POT7S3J/uvN+77707z+/3nXsthAAhhBD//0kM9QSEEEKcGJTQhRAiJiihCyFETFBCF0KImKCELoQQMUEJXQghYsKAErqZXWpmW8xsm5ndfqImJYQQ4vix/urQzSwJYCuAiwDsBbAawLUhhI3MJ1lWGgoqK/3BHNlOERkAELrJ51EB3yfrMf+9UtwnkeRzyPX6c0h0+tsBgFyabCsRcSx6yL6m+Nysi39eh0KyrcDnXVHa7tpbG0upT66IbCZJXTjG45OMiEM242/MsnxTgYQuXZqhPplmf2dzKb6dqDmg2N8net6Dz6+rlRwIAEZClyvq53dUcuQcijh+9Lwr4McV5NpDMmo7fCjRRXJDQcTbFZL5Zfl11J/b6O6dNftDCGOP9ncRUz0qiwFsCyFsBwAzexDAlQBoQi+orETVbbe4Y8lOfy9tip9EACBXU+Las5U91CdVW+jae6q6qU9ZRScda2vwk9mIjfwqbjndn1+itJf6WJ1/QYbxPMEUbU7Tsc7p/v5aJ8+0Hz1ntWt/4XtnUZ+2Kb69pyLiQmWfNREf7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FEL5iZqMxjOJwmPwjly+EEC4fbjEws+nouysH+h6D3x9C+Gp/4qBvigohREzQN0WFECImKKELIURMUEIXQoiYoIQuhBAxQQldCCFighK6EELEBCV0IYSICUroQggRE/4bdYmDYkl2gyoAAAAASUVORK5CYII=",
|
|
"text/plain": [
|
|
"<Figure size 432x288 with 1 Axes>"
|
|
]
|
|
},
|
|
"metadata": {
|
|
"needs_background": "light"
|
|
},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"# equivalent to least squares\n",
|
|
"n = 816\n",
|
|
"s0 = np.zeros(816)\n",
|
|
"s0[:n] = s[:n]\n",
|
|
"C0 = np.dot(u, np.dot(np.diag(s0), vh))\n",
|
|
"A0_guess = vec2mat(np.linalg.pinv(C0) @ a, (16, 51))\n",
|
|
"plt.imshow(A0_guess)\n",
|
|
"plt.show()"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 46,
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "slide"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXwAAAD4CAYAAADvsV2wAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAhRUlEQVR4nO3deXxV5YH/8c9zs+97QlaTELYAYRUEwb0KVtGp1sHWGdtBGbtN22lnqtNOW3+dTpexrW3HsTrW1rEuo47jgrS4gVSlSJA1QICEQEJCNrKRELLc5/dHLjYygIEs59x7v+/XK6/ce3Jzz5ebyzcnz3nOOcZai4iIBD6P0wFERGRsqPBFRIKECl9EJEio8EVEgoQKX0QkSIQ6HeBsUlNTbX5+vtMxRET8xubNm5ustWmn+5qrCz8/P5/S0lKnY4iI+A1jzMEzfU1DOiIiQUKFLyISJFT4IiJBQoUvIhIkVP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R2B+3yfkwc9/pu+nOXA0lHKtIiBPwm3A1t9H9c6mQsoAbb4Mu0Evu1b7uhrNWhdl/HnnbZO//wKGZi1sQ0oO/medkGumUCp72f4ApDkdCbfeqKBZiBh0DKnX6t7Gdig2Qk8zsAMHEcy6dQKIiJBItCGdERE5AxU+CIiQUKFLyISJFT4IiJBQoUvIhIkVPgiIkFChS8iEiT+Pypxs02vXZ7eAAAAAElFTkSuQmCC",
|
|
"text/plain": [
|
|
"<Figure size 432x288 with 1 Axes>"
|
|
]
|
|
},
|
|
"metadata": {
|
|
"needs_background": "light"
|
|
},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"plt.plot(s0)\n",
|
|
"plt.yscale('log');"
|
|
]
|
|
},
|
|
{
|
|
"cell_type": "code",
|
|
"execution_count": 47,
|
|
"metadata": {
|
|
"slideshow": {
|
|
"slide_type": "fragment"
|
|
}
|
|
},
|
|
"outputs": [
|
|
{
|
|
"data": {
|
|
"image/png": "iVBORw0KGgoAAAANSUhEUgAAAXQAAACJCAYAAAA8GMMgAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjUuMSwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy/YYfK9AAAACXBIWXMAAAsTAAALEwEAmpwYAAAUyElEQVR4nO2dXYwk11XH/6eqq7vna2e/1/baiUNkiUQWMdLKCjIPToDIgIXDQ1AsIfkBsTwQKUggZPISQIrECx8vCMkQy5YgCZbAxEIWiWWCzBN4DYE42AHLcuzVzu7sx8zOV39Udx8epgcm9v2fmemenXZq/j9pNd339q26fU7Vqdq6/z7H3B1CCCF++MkmPQEhhBD7gwK6EEJUBAV0IYSoCAroQghRERTQhRCiIiigCyFERRgroJvZQ2b2PTN7w8we369JCSGE2Ds2qg7dzHIA/w3gZwBcBPAygEfd/b/YmHo+7VPFkWSfF3myfVDj1xxPD6HtAOBkc258zChYZNbB3sfYCGPYfjbHHczvD9yIYQN7U1+MMmaHcfsKMWm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pnZz2Hz2VkO4El3/9KBT2ICkMyVfwfgGQAfAPA2gM+4e2VL/pnZTwL4ZwDfwf8/N/0CNp+jHyY7/Bg2F7pybN5YPePuv29mJ3CI7LDF8JHLb7n7w4fNBmb2I9i8Kwc2H4N/xd2/NIod9EtRIYSoCPqlqBBCVAQFdCGEqAgK6EIIUREU0IUQoiIooAshREVQQBdCiIqggC6EEBVBAV0IISrC/wL089BcaKPlCQAAAABJRU5ErkJggg==",
|
|
"text/plain": [
|
|
"<Figure size 432x288 with 1 Axes>"
|
|
]
|
|
},
|
|
"metadata": {
|
|
"needs_background": "light"
|
|
},
|
|
"output_type": "display_data"
|
|
}
|
|
],
|
|
"source": [
|
|
"n = 10\n",
|
|
"s0 = np.zeros(816)\n",
|
|
"s0[:n] = s[:n]\n",
|
|
"C0 = np.dot(u, np.dot(np.diag(s0), vh))\n",
|
|
"A0_guess = vec2mat(np.linalg.pinv(C0) @ a, (16, 51))\n",
|
|
"plt.imshow(A0_guess)\n",
|
|
"plt.show()"
|
|
]
|
|
}
|
|
],
|
|
"metadata": {
|
|
"celltoolbar": "Slideshow",
|
|
"kernelspec": {
|
|
"display_name": "Python 3.10.8 ('nummethods')",
|
|
"language": "python",
|
|
"name": "python3"
|
|
},
|
|
"language_info": {
|
|
"codemirror_mode": {
|
|
"name": "ipython",
|
|
"version": 3
|
|
},
|
|
"file_extension": ".py",
|
|
"mimetype": "text/x-python",
|
|
"name": "python",
|
|
"nbconvert_exporter": "python",
|
|
"pygments_lexer": "ipython3",
|
|
"version": "3.10.8"
|
|
},
|
|
"vscode": {
|
|
"interpreter": {
|
|
"hash": "8d489487a004dbbc79692a52da1077223bea5d5bb7772308e4a4df2310821984"
|
|
}
|
|
}
|
|
},
|
|
"nbformat": 4,
|
|
"nbformat_minor": 4
|
|
}
|