Blog

A short introduction to eigenvectors

26 May 2011 - By Anders Hørsted

Let \(A\) be a \(n \times n\) matrix and \(v\) a n-dimensional column vector. The eigenvectors and eigenvalues of \(A\) are defined by the equation $$ Av = \lambda v\:,\quad v \neq 0 $$ Any \(v\) and \(\lambda\in\mathbb{R}\) satisfying the equation are called respectively the eigenvector and the eigenvalue of \(A\). If the above equation is rearange a bit we get $$ (A - \lambda I)v = 0 $$ Since we are not interested in the solution \(v=0\), the matrix \(A-\lambda I\) has to be singular, which implies that $$ \det(A-\lambda I) = 0 $$ The expression \(\det(A-\lambda I)\) regarded as a function of \(\lambda\) is a polynomium of maximum \(n\)-degree and the roots of the polynomium are the eigenvalues of \(A\). For every eigenvalue of \(A\) the solutions to the homogeneous matrixequation $$ (A - \lambda I)v = 0 $$ are called the eigenvectors of \(A\). An example will clarify the above.

Let the matrix \(A\) be given by $$ A = \begin{bmatrix} 1 & 2 \\ 3 & 0 \end{bmatrix} $$ Then we have $$ A - \lambda I = \begin{bmatrix} 1 - \lambda & 2 \\ 3 & -\lambda \end{bmatrix} $$ and therefore \begin{align} \det(A - \lambda I) &= (1-\lambda)(-\lambda) - 6 \\ &= \lambda^2 - \lambda - 6 \end{align} Now we can find the roots of the polynomium \begin{gather} \lambda^2 - \lambda - 6 = 0 \quad\Rightarrow\quad \lambda_1 = 3 \:\land\: \lambda_2 = -2 \end{gather} The eigenvalues of \(A\) are found to be \(3\) and \(-2\). To find the eigenvectors belonging to the first eigenvalue \(\lambda_1=3\) we write \begin{align} A-3I &= \begin{bmatrix} 1-3 & 2 \\ 3 & -3 \end{bmatrix} \\ &= \begin{bmatrix} -2 & 2 \\ 3 & -3 \end{bmatrix} \\ &\sim \begin{bmatrix} 1 & -1 \\ 0 & 0 \end{bmatrix} \end{align} Since \begin{align} A-3I \sim \begin{bmatrix} 1 & -1 \\ 0 & 0 \end{bmatrix} \end{align} we get the solution to the homogeneous equation \((A-3I)v=0\) as $$ v = s\begin{bmatrix} -1 \\ 1 \end{bmatrix},\quad s\in\mathbb{R} $$ All eigenvectors of \(A\) belonging to the eigenvalue \(\lambda_1=3\) are therefore given by $$ E_{\lambda_1} = \text{span}\{\begin{bmatrix}-1 & 1\end{bmatrix}^T\} $$ By the same procedure we get that all eigenvectors of \(A\) belonging to the eigenvalue \(\lambda_2=-2\) are $$ E_{\lambda_2} = \text{span}\{\begin{bmatrix}2 & -3\end{bmatrix}^T\} $$

Approximating the normal distribution

24 May 2011 - By Anders Hørsted

As a little exercise I have created a javascript application that calculates probabilities for an arbitrary normal distribution. Since no analytical expression for the cumulative prbability distribution exists, I had to find a way to approximate it.
If a stochastic variable \(X\) is normal distributed with mean \(\mu\) and standard deviation \(\sigma\), the stochastic variable $$ Z=\frac{X-\mu}{\sigma} $$ is standard normal distributed. We therefore only need to find a way to calculate probabilities of the standard normal distribution, to be able to calculate an arbitrary normal distribution. The standard normal distribution has the cumulative density function (cdf) $$ F(x) = \frac{1}{\sqrt{2\pi}} \int_{-\infty}^x e^{-t^2/2}\,\text{dt} $$ Unfortunately this integral can't be solved analytically, so we can only approximate it. We will approximate it with a series representation of the ingral, but to make the following calculations easier, we first look at some properties of the cdf of the standard normal distribution. First of all, since the probability density function (pdf) of the standard normal distribution is symmetric around \(x=0\), the following holds $$ F(-x) = 1 - F(x) $$ Therefore we only need to calculate \(F(x)\) for positive values of \(x\). Another result of the symmetric pdf, is that \(F(0)=0.5\) and therefore $$ F(x) = 0.5 + \frac{1}{\sqrt{2\pi}} \int_{0}^x e^{-t^2/2}\,\text{dt} $$ Now we need to approximate the above integral. First we can replace the exponential function with its series representation $$ F(x) = 0.5 + \frac{1}{\sqrt{2\pi}} \int_{0}^x \left(\sum_{n=0}^\infty \frac{(-t^2/2)^n}{n!}\right) \,\text{dt} $$ Since the series converges for all values of \(t\), we are allowed to switch the summation and the integration which gives \begin{align} F(x) &= 0.5 + \frac{1}{\sqrt{2\pi}} \sum_{n=0}^\infty\frac{(-1)^n}{2^n n!} \left(\int_{0}^x t^{2n} \,\text{dt}\right) \\ &= 0.5 + \frac{1}{\sqrt{2\pi}} \sum_{n=0}^\infty\frac{(-1)^n}{2^n n!} \left[\frac{t^{2n+1}}{2n+1}\right]_{t=0}^x \\ &= 0.5 + \frac{1}{\sqrt{2\pi}} \sum_{n=0}^\infty\frac{(-1)^n x^{2n+1}}{2^n n! (2n+1)} \end{align} With this series the cdf of the standard normal distribution can be approximated by selecting \(N\) and then calculate $$ F_N(x) = 0.5 + \frac{1}{\sqrt{2\pi}} \sum_{n=0}^N\frac{(-1)^n x^{2n+1}}{2^n n! (2n+1)} $$ The error that is made by only calculating the first \(N\) terms is bounded by $$ |F(x) - F_N(x)| \leq \frac{x^{2N+3}}{2^{N+1} (N+1)! (2N+3)} $$ By selecting \(N\) large enough we can therefore get an arbitrarily small error.

Welcome to my new blog

15 May 2011 - By Anders Hørsted

Welcome to my new blog. I used to blog at tanketorsken.dk but have chosen to move all my web activity to my company web site. This site. I hope you enjoy.