{ "cells": [ { "cell_type": "raw", "metadata": {}, "source": [ "[Table of Contents](table_of_contents.ipynb)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "# Topic 18. Cholesky Factorization\n", "Author: David Wood, d.wood0403@gmail.com; John Hunt, john.hunt92@gmail.com\n", " " ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Introduction\n", "The factorization is named after Andre-Louis Cholesky, a French military officer involved in geodetics engineering. Andre-Louis Cholesky lived from 1875 to 1918, killed in World War I (WWI). He attented the renowned university École Polytechnique in France, where the first discoveries about radioactivity occurred. Cholesky survyed Crete and North Africa before WWI. Before the war Cholesky created and used the Cholesky decomposition in his survying.\n", "\n", "The Cholesky decomposition is the decomposition of a Hermitian, positive-definite matrix into the product of a lower triangular matrix and its conjugate transpose, which is useful for efficient numerical solutions, e.g. Monte Carlo simulations and systems with multiple correlated variables (a system with independant variables would result in matrices that are not Hermitian, positive-deffinite and thus non solvable with this method). \n", "\n", "The Cholesky decomposition is also closely related to the solution of least-squares problems, since the normal equations that characterize the least-squares solution have a symmetric positive-definite coefficient matrix. When it is applicable, the Cholesky decomposition is roughly twice as efficient as the LU decomposition for solving systems of linear equations. It can also be used to calculate and use correlation matrices in experiment statistics. In the case of a scalar (n = 1), the Cholesky factor $ R $ is just the positive square root of $ A $. However, $ R $ should not be confused with the square roots of $ A $." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Explanation of the theory\n", "\n", "The Cholesky factorization can be thought of, with caution (see above), as finding the general square root of matrix $ A $. Using this type of factorization, we factor $ A $ into a single matrix $ L $ multiplied by itself $ A=L L^{T} $ or $ A=R^{T} R $. In the case of a scalar (n = 1), the Cholesky factor $ R $ is just the positive square root of $ A $. However, $ R $ should not be confused with the square roots of $ A $.\n", "\n", "Every positive definite matrix $ A $ has a Cholesky factorization if there exists a lower trianglar matrix $ L $ that contains positive diagonal elements such that $ A=L L^{T} $. In summary, Cholesky factorization is a specific form of LU decomposition where $ U=L^{T} $. This fact makes computing $ L $ much easier.\n", "\n", "__Theorem :__ Every positive definite matrix $ A $ has a Cholesky factorization which may be constructed.\n", "\n", "_Proof:_ Using induction on an $ n-1 \\space \\times \\space n-1 $ matrix, we can prove the result for the trivial $ 1 \\space \\times \\space 1 $ positive definite matrix $ A $ and extend it to an $ n \\space \\times \\space n $ matrix. For the $ 1 \\space \\times \\space 1 $ positive definite matrix $ A = [a_{11}] $, $ a_{11} > 0 $. Therefore $ L=[l_{11}] $ where $ l_{11}=sqrt(a_{11}) $. This result then can be extended to any positive definite matrix $ A $.\n", "\n", "Since $ A $ is positive definite, it is symmetric and can be represented as \n", "\n", "$$ A = \n", " \\begin{bmatrix}\n", " a_{11} & A_{21}^{T} \\\\\n", " A_{21} & A_{22} \\\\\n", " \\end{bmatrix}$$\n", " \n", " Since $ A $ is positive definite, $ a_{11} > 0 $, and thus we can easily determine that $ l_{11} = \\sqrt{a_{11}} $ and $ L_{21} = \\frac{1}{l_{11}} \\space A_{21} $.\n", " \n", " We can now show that \n", " \n", "$$ K=A_{22} \\space - \\space L_{21} L_{21}^{T} $$\n", "\n", "is a positive definite matrix as well. For any $n-1 \\space \\times \\space 1 $ column vector $ X \\neq 0 $ and let\n", "\n", "$$ V = -\\frac{1}{a_{11}} A_{21}^{T} X $$\n", " \n", "Then\n", "\n", "$$ X^{T}KX \\space = \\space [V \\space X^{T}] A \\begin{bmatrix}\n", " V \\\\\n", " X \\\\\n", " \\end{bmatrix} \\space > \\space 0 $$\n", " because $ A $ is positive definite. Since\n", " \n", " $$ A_{22}-L_{21}L_{21}^{T} $$\n", " \n", " is a positive definite $ n-1 \\space \\times \\space n-1 $ matrix, there is a lower triangular matrix that contains all positive elements such that \n", " \n", "$$ A_{22}-L_{21}L_{21}^{T}=L_{22}L_{22}^{T}$$\n", "\n", "Therefore\n", "\n", "$$ A = \n", " \\begin{bmatrix} a_{11} & A_{21}^{T} \\\\ A_{21} & A_{22} \\\\ \\end{bmatrix} = \n", " \\begin{bmatrix} l_{11} & 0 \\\\ L_{21} & L_{22} \\\\ \\end{bmatrix}\n", " \\begin{bmatrix} l_{11} & L_{21}^{T} \\\\ 0 & L_{22}^{T} \\\\ \\end{bmatrix}$$\n", " \n", "__Complete Algebra__\n", "Using a 3x3 matrix, we will show the Cholesky factorization in its entirety which may be coded. As an example, we have to solve the following system of equations:\n", "\n", "$$ A = \n", " \\begin{bmatrix} a_{11} & a_{21} & a_{31} \\\\\n", " a_{21} & a_{22} & a_{32} \\\\\n", " a_{31} & a_{32} & a_{33} \\\\ \\end{bmatrix} = \n", " \\begin{bmatrix} l_{11} & 0 & 0\\\\\n", " l_{21} & l_{22} & 0 \\\\\n", " l_{31} & l_{32} & l_{33} \\\\ \\end{bmatrix}\n", " \\begin{bmatrix} l_{11} & l_{21} & l_{31} \\\\\n", " 0 & l_{22} & l_{32} \\\\\n", " 0 & 0 & l_{33} \\\\ \\end{bmatrix} = LL^{T} $$\n", " \n", " $$ = \\begin{bmatrix} l_{11}^{2} & l_{11} l_{21} & l_{11} a_{31} \\\\\n", " l_{11} l_{21} & l_{21}^{2} + l_{22}^{2} & l_{31} l_{21} + l_{32} l_{22} \\\\\n", " l_{11} l_{31} & l_{31} l_{21} + l_{32} l_{22} & l_{31}^{2} + l_{32}^{2} + l_{33}^{2} \\\\ \\end{bmatrix} $$\n", " \n", " We can easily see that the diagonal elements have a pattern. In general:\n", " \n", " $$ l_{ii} = \\sqrt{a_{ii} - \\sum_{j=1}^{i-1} l_{ij}^{2}} $$\n", " \n", "For off-diagonal elements ($ l_{ij}$) there is also a pattern:\n", "\n", "$$ l_{21}=\\frac{1}{l_{11}} a_{21} $$\n", "$$ l_{31}=\\frac{1}{l_{11}} a_{31} $$\n", "$$ l_{32}=\\frac{1}{l_{22}} (a_{32} - l_{21}l_{31})$$\n", "\n", "which in general terms is:\n", "\n", "$$ l_{ij} = \\frac{1}{l_{jj}}(a_{ij} - \\sum_{k=1}^{j-1} l_{ik}l_{jk}) \\qquad i > j $$\n", " \n", "__Use in linear algebra__\n", "To solve linear systems of equations, Cholesky factorization can be used when computing $ A^{-1} $ is difficult or computationally expensive - as is the case for large systems. To solve equations in $ Ax=b $ form, we only have to perform one intermediate step before solving for $ \\textbf{x} $. This comes from the fact that once $ A $ is factored into $ L L^{T} $ we can redefine the equation with a temporary vector $ \\textbf{y} $ \n", "\n", "$$ Ax \\space = \\space L(L^{T}x) \\space = \\space Ly \\space = \\space b$$\n", "\n", "Once $ A $ is factored into $ L L^{T} $ we must use forward substitution to solve for the temporary vector $ \\textbf{y} $ using\n", "\n", "$$ Ly \\space = \\space \\begin{bmatrix} l_{11} & 0 \\\\ L_{21} & L_{22} \\\\ \\end{bmatrix} \\begin{bmatrix} y_{1} \\\\ y_{2} \\\\ \\end{bmatrix} \\space = \\space \\begin{bmatrix} b_{1} \\\\ b_{2} \\\\ \\end{bmatrix} \\space = \\space b $$\n", "\n", "Then, having found $ \\textbf{y} $, the next step is use backward substitution to solve for $ \\textbf{x} $ in\n", "\n", "$$ L^{T}x \\space = \\space \\begin{bmatrix} l_{11} & L_{21} \\\\ 0 & L_{22} \\\\ \\end{bmatrix} \\begin{bmatrix} x_{1} \\\\ x_{2} \\\\ \\end{bmatrix} \\space = \\space \\begin{bmatrix} y_{1} \\\\ y_{2} \\\\ \\end{bmatrix} \\space = \\space y $$\n", "\n", "Both forward substitution and backward substitution can be performed by directly solving each equation in the system sequentially.\n", "\n", "Additionally, the Cholesky factorization could also be written as $ A=U^{H} U $. Where $ U $ = $ L^{H} $. Here $ U $ is an upper triangle matrix instead of a lower triangle matrix. This could be useful if a solver for an upper triangle has already been implemented then the order of the matrix can change my taking the Hermitian of the L matrix. \n", "\n", "Example:\n", "\n", "\n", "$$ A = \n", "\\begin{bmatrix} \n", " 1 & 2 & 4 & 1 \\\\\n", " 2 & 13 & 17 & 8 \\\\\n", " 4 & 17 & 29 & 16 \\\\ \n", " 1 & 8 & 16 & 30 \\\\ \n", " \\end{bmatrix} = LL^{T}$$\n", " \n", " \n", "$$ LL^{H} = \n", "\\begin{bmatrix} \n", " 1 & 0 & 0 & 0 \\\\\n", " 2 & 3 & 0 & 0 \\\\\n", " 4 & 3 & 2 & 0 \\\\ \n", " 1 & 2 & 3 & 4 \\\\ \n", " \\end{bmatrix}\n", " \\begin{bmatrix} \n", " 1 & 2 & 4 & 1 \\\\\n", " 0 & 3 & 3 & 2 \\\\\n", " 0 & 0 & 2 & 3 \\\\ \n", " 0 & 0 & 0 & 4 \\\\ \n", " \\end{bmatrix}\n", " $$\n", " \n", " $$ L^{H} = U = \n", "\\begin{bmatrix} \n", " 1 & 2 & 4 & 1 \\\\\n", " 0 & 3 & 3 & 2 \\\\\n", " 0 & 0 & 2 & 3 \\\\ \n", " 0 & 0 & 0 & 4 \\\\ \n", " \\end{bmatrix}$$\n", " \n", " $$ A = \n", "\\begin{bmatrix} \n", " 1 & 2 & 4 & 1 \\\\\n", " 2 & 13 & 17 & 8 \\\\\n", " 4 & 17 & 29 & 16 \\\\ \n", " 1 & 8 & 16 & 30 \\\\ \n", " \\end{bmatrix} = U^{H}U = \n", " \\begin{bmatrix} \n", " 1 & 0 & 0 & 0 \\\\\n", " 2 & 3 & 0 & 0 \\\\\n", " 4 & 3 & 2 & 0 \\\\ \n", " 1 & 2 & 3 & 4 \\\\ \n", " \\end{bmatrix}\n", " \\begin{bmatrix} \n", " 1 & 2 & 4 & 1 \\\\\n", " 0 & 3 & 3 & 2 \\\\\n", " 0 & 0 & 2 & 3 \\\\ \n", " 0 & 0 & 0 & 4 \\\\ \n", " \\end{bmatrix}\n", " $$\n", " \n", " \n", " By inspection it can be seen that $ U^{H}U $ = $ LL^{H} $" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Simple Numerical Examples\n", "\n", "Provide some simple python code and examples that emphasize the basic concepts.\n", "\n", "### python code of Cholesky decomposition" ] }, { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "A:\n", "[[6, 3, 4, 8], [3, 6, 5, 1], [4, 5, 10, 7], [8, 1, 7, 25]] \n", "\n", "\n", "L:\n", "[[2.449489742783178, 0.0, 0.0, 0.0], [1.2247448713915892, 2.1213203435596424, 0.0, 0.0], [1.6329931618554523, 1.414213562373095, 2.309401076758503, 0.0], [3.2659863237109046, -1.4142135623730956, 1.5877132402714704, 3.1324910215354165]] \n", "\n", "\n" ] } ], "source": [ "from math import sqrt\n", "#from pprint import pprint\n", "\n", "def cholesky(A):\n", " L = [[0.0] * len(A) for _ in range(len(A))]\n", " for i, (Ai, Li) in enumerate(zip(A, L)):\n", " for j, Lj in enumerate(L[:i+1]):\n", " s = sum(Li[k] * Lj[k] for k in range(j))\n", " Li[j] = sqrt(Ai[i] - s) if (i == j) else \\\n", " (1.0 / Lj[j] * (Ai[j] - s))\n", " return L\n", " \n", "A = [[6, 3, 4, 8], [3, 6, 5, 1], [4, 5, 10, 7], [8, 1, 7, 25]]\n", "L = cholesky(A)\n", "\n", "print(\"A:\")\n", "print(A, '\\n\\n')\n", "\n", "print(\"L:\")\n", "print(L, '\\n\\n')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In its entirely, explicitly coding Cholesky factorization can be an arduous task and greatly taxes a computer's computational capacity if $A$ becomes too large. Thankfully, the SciPy library has a built in Cholesky decomposition function - scipy.linalg.cholesky - that does the calculations while requiring only a fraction of the computation power. Below is the same example using SciPy's built in functions." ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "A:\n", "[[ 6 3 4 8]\n", " [ 3 6 5 1]\n", " [ 4 5 10 7]\n", " [ 8 1 7 25]] \n", "\n", "\n", "L:\n", "[[ 2.44948974 0. 0. 0. ]\n", " [ 1.22474487 2.12132034 0. 0. ]\n", " [ 1.63299316 1.41421356 2.30940108 0. ]\n", " [ 3.26598632 -1.41421356 1.58771324 3.13249102]] \n", "\n", "\n", "U:\n", "[[ 2.44948974 1.22474487 1.63299316 3.26598632]\n", " [ 0. 2.12132034 1.41421356 -1.41421356]\n", " [ 0. 0. 2.30940108 1.58771324]\n", " [ 0. 0. 0. 3.13249102]] \n", "\n", "\n" ] } ], "source": [ "#import pprint\n", "import scipy\n", "import scipy.linalg # SciPy Linear Algebra Library\n", "\n", "A = scipy.array([[6, 3, 4, 8], [3, 6, 5, 1], [4, 5, 10, 7], [8, 1, 7, 25]])\n", "L = scipy.linalg.cholesky(A, lower=True)\n", "U = scipy.linalg.cholesky(A, lower=False)\n", "\n", "print(\"A:\")\n", "print(A, '\\n\\n')\n", "\n", "print(\"L:\")\n", "print(L, '\\n\\n')\n", "\n", "print(\"U:\")\n", "print(U, '\\n\\n')" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As you can see, both implementations of Cholesky factorization gave the same answer. However, in the example were we created the Cholesky function we only have the lower triangle matrix. The transposed lower triangle matrix may also be calculated with additional coding.\n", "\n", "### Matlab code of Cholesky decomposition (copy and paste in Matlab for application)\n", "\n", "%% Cholesky Factorization\n", "\n", "% -- User Information (Matrix and olution vector)-- %\n", "\n", "B = [1 2 4 1; 2 13 17 8; 4 17 29 16; 1 8 16 30];\n", "\n", "b = [2;2;2;2];\n", "\n", "% B = [6 15 55; 15 55 225; 55 225 979];\n", "\n", "[row, col] = size(B);\n", "\n", "[V, D] = eig(B);\n", "\n", "d = [];\n", "\n", "for i=1:length(D)\n", "\n", " d = [d;D(i,i)];\n", " \n", "end\n", "\n", "if sum(d>0)==length(d) && row*row == sum(sum(B - B' == 0))% -- Check if matrix is PSD & Symmetry -- %\n", "\n", " L = zeros(row,col);\n", " \n", " for i = 1:row\n", " \n", " for j = 1:col\n", " \n", " if j > i\n", " \n", " L(i,j) = 0;\n", " \n", " elseif j == i\n", " \n", " num = 0;\n", " \n", " for k = 1:row-1\n", " \n", " num = num + L(i,k)^2;\n", " \n", " end\n", " \n", " L(i,j) = sqrt(B(i,j) - num);\n", " \n", " else\n", " \n", " num = 0;\n", " \n", " for k = 1:row-1\n", " \n", " num = num + L(j,k)*L(i,k);\n", " \n", " end\n", " \n", " L(i,j) = (B(i,j)-num)/L(j,j);\n", " \n", " end\n", " \n", " end\n", " \n", " end\n", " \n", "else\n", "\n", " disp('Cannot use Cholesky Factorization b/c it is not symmetric or it is not positive semi definite')\n", " \n", "end\n", "\n", "% -- Solve -- %\n", "\n", "y = L\\(b);\n", "\n", "x = L'\\y\n", "\n", "ANSWER\n", "\n", "L = [1,0,0,0;2,3,0,0;4,3,2,0;1,2,3,4]\n", "\n", "x = [5.97222222222222;\n", " 1.15972222222222;\n", " -1.68750000000000;\n", " 0.458333333333333]\n", " \n", "In addition $ Matlab $ has prebuilt functions as well, below is an example using those functions.\n", "\n", "\n", "A = [1 2 4 1; 2 13 17 8; 4 17 29 16; 1 8 16 30]\n", "\n", "(or you can read in data from a file and continue)\n", "\n", "L = chol(A)\n", "\n", "y = L\\(b);\n", "\n", "x = L'\\y\n", "\n", "The answer is the same as the example above." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## An Engineering Application\n", "\n", "Two main uses of the Cholesky decomposition in engineering are to solve a least squares problem - because the Cholesky factorization requires less computational power to compute and solve than QR or LU - and random sampling of a multivariate Normal distribution. It can be used to decompose a covariance matrix because these matrices may only be positive semi-definite - one of the prerequisites to using the Cholesky decomposition.\n", "\n", "Here we will solve a problem for $ \\textbf{x} $ that is defined by a system of 3 equations.\n", "\n", "__Example 2:__ A system is defined by the equations below\n", "\n", "$$ \\begin{bmatrix} 4 & 2 & 14 \\\\ 2 & 17 & -5 \\\\ 14 & -5 & 83 \\\\ \\end{bmatrix}\n", "\\begin{bmatrix} x_{1} \\\\ x_{2} \\\\ x_{3} \\\\ \\end{bmatrix} =\n", "\\begin{bmatrix} 14 \\\\ -101 \\\\ 155 \\\\ \\end{bmatrix} $$\n", "\n", "Using Cholesky decomposition, we find \n", "\n", "$$ L = \\begin{bmatrix} 2 & 0 & 0 \\\\ 1 & 4 & 0 \\\\ 7 & -3 & 5 \\\\ \\end{bmatrix} $$\n", "\n", "$$ L^{T} = \\begin{bmatrix} 2 & 1 & 7 \\\\ 0 & 4 & -3 \\\\ 0 & 0 & 5 \\\\ \\end{bmatrix} $$\n", "\n", "First solving $ Ly=b $ with forward substitution\n", "\n", "$$ \\textbf{y} = \\begin{bmatrix} 7 & -27 & 5 \\\\ \\end{bmatrix} $$\n", "\n", "then solving $ L^{T}y=b $ with backward substitution, finally gives a result of\n", "\n", "$$ \\textbf{x} = \\begin{bmatrix} 3 & -6 & 1 \\\\ \\end{bmatrix} $$\n", "\n", "__Example 2:__ We can also use the factorization to generate a random sampling from the multivariate Normal distribution $ Z \\space \\approx \\space N(0,I) $ where the affine transformation\n", "\n", "$$ Y \\space = \\space QX \\space + \\space \\mu $$\n", "\n", "is to be approximated. The variable $Y$ are the random samples that are generated, $X$ are the samples from the known univariate Normal distribution, and Q is defined as follows:\n", "\n", "$$ Q \\space = \\space \\lambda^{1/2} \\Phi $$\n", "\n", "where $\\lambda$ is a diagonal matrix containing the eigenvalues of the target matrix $\\Sigma$, and $\\Phi$ contains the associated eigenvectors of $\\Sigma$ arranged to match their eigenvalues in $\\lambda$. \n", "\n", "Note that $Y$ has the distribution \n", "\n", "$$ Y \\space \\approx \\space N(\\mu,QQ') $$\n", "\n", "We use the Cholesky decompositon because we want $\\Sigma = QQ'$. Therefore, to simulate (or sample) $Z$ we can use $ X \\space \\approx \\space N(\\mu,\\Sigma) $ which is less computationally expensive to calculate.\n" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Future Homework\n", "\n", "Use the Cholesky decomposition to transform 10 normal distributed independent (and thus uncorrelated) random variables with mean of 0 and variance of 1 - N(0,1) to correlated variables in using Matlab or python libraries with the following covariance matrix (please copy and paste this in Matlab or python)\n", "\n", "$$ K_{xx} = \n", "\\begin{bmatrix}\n", " 1 & 2 & 3 & 5 & -1 & 1 & -2 & 5 & 8 & 1 \\\\\n", " 2 & 13 & 18 & 37 & 4 & 8 & 5 & 37 & 22 & 5 \\\\\n", " 3 & 18 & 50 & 46 & 20 & 41 & 26 & 56 & 37 & 17 \\\\\n", " 5 & 37 & 46 & 111 & 18 & 27 & 23 & 121 & 75 & 16 \\\\\n", " -1 & 4 & 20 & 18 & 55 & 61 & 50 & 63 & 50 & 40 \\\\\n", " 1 & 8 & 41 & 27 & 61 & 91 & 88 & 90 & 96 & 60 \\\\\n", " -2 & 5 & 26 & 23 & 50 & 88 & 143 & 104 & 116 & 86 \\\\\n", " 5 & 37 & 56 & 121 & 63 & 90 & 104 & 223 & 199 & 110 \\\\\n", " 8 & 22 & 37 & 75 & 50 & 96 & 116 & 199 & 285 & 175 \\\\\n", " 1 & 5 & 17 & 16 & 40 & 60 & 86 & 110 & 175 & 230 \\\\ \n", " \\end{bmatrix}$$\n", " \n", "and\n", " \n", "$$ SD =\n", "\\begin{bmatrix}\n", " 1\\\\\n", " 3.60555127546399 \\\\\n", " 7.07106781186548 \\\\\n", " 10.5356537528527 \\\\\n", " 7.41619848709566 \\\\\n", " 9.53939201416946 \\\\\n", " 11.9582607431014 \\\\\n", " 14.9331845230681 \\\\\n", " 16.8819430161341 \\\\\n", " 15.1657508881031 \\\\\n", " \\end{bmatrix}$$\n", " \n", " (Maybe put a file on LS?)\n", " \n", "\n", "Please turn in the following:\n", "1) A plot of the uncorrelated variables as well as the correlated variables (using subplot in Matlab or pairplot from seaborn library in python will be helpful).\n", "\n", "2) An explination of why your plots shows that applying the cholesky decompotision correlates the random variables." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Future Homework Solutions\n", "\n", "MATLAB CODE \n", "\n", "% Solution\n", "\n", "mu = 0; sigma = 1; sz = 10;\n", "\n", "x_uncor = normrnd(mu,sigma,sz);\n", "\n", "% Uncorrelated Plots\n", "\n", "figure(1); count = 1;\n", "\n", "for i = 1:10\n", "\n", " for j = 1:10\n", " \n", " subplot(10,10,count)\n", " \n", " scatter(x_uncor(:,i),x_uncor(:,j))\n", " \n", " count = count + 1;\n", " \n", " end\n", " \n", "end\n", "\n", "L = chol(Kxx);\n", "\n", "x_cor = L*Kxx;\n", "\n", "% Correlated Plots\n", "\n", "figure(2); count = 1;\n", "\n", "for i = 1:10\n", "\n", " for j = 1:10\n", " \n", " subplot(10,10,count)\n", " \n", " scatter(x_cor(:,i),x_cor(:,j))\n", " \n", " count = count + 1;\n", " \n", " end\n", " \n", "end" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "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.8.6" } }, "nbformat": 4, "nbformat_minor": 2 }