User:FizykLJF/sandbox

Formula test
Formula from AppQM:

\begin{matrix} i\frac{\text{d}}{\text{d}t}a_1(t)=\Omega \,\text{e}^{+i(\omega - \omega_{0})\,t}a_2(t)\\ \\   i\frac{\text{d}}{\text{d}t}a_2(t)=\Omega \,\text{e}^{-i(\omega - \omega_{0})\,t}a_1(t)\\ \end{matrix} $$

Sections to replace Covariance matrix#Block matrices

Block matrices
The joint mean $$\mathbf\mu$$ and joint covariance matrix $$\mathbf\Sigma$$ of $$\mathbf{X}$$ and $$\mathbf{Y}$$ can be written in block form



\mathbf\mu = \begin{bmatrix} \mathbf{\mu_X} \\ \mathbf{\mu_Y} \end{bmatrix}, \qquad \mathbf\Sigma = \begin{bmatrix} \operatorname{K}_\mathbf{XX} & \operatorname{K}_\mathbf{XY} \\ \operatorname{K}_\mathbf{YX} & \operatorname{K}_\mathbf{YY} \end{bmatrix} $$

where $$ \operatorname{K}_\mathbf{XX} = \operatorname{var}(\mathbf{X}) $$, $$ \operatorname{K}_\mathbf{YY} = \operatorname{var}(\mathbf{Y}) $$ and $$ \operatorname{K}_\mathbf{XY} = \operatorname{K}^{\rm T}_\mathbf{YX} = \operatorname{cov}(\mathbf{X}, \mathbf{Y}) $$.

$$ \operatorname{K}_\mathbf{XX} $$ and $$ \operatorname{K}_\mathbf{YY} $$ can be identified as the variance matrices of the marginal distributions for $$ \mathbf{X} $$ and $$ \mathbf{Y} $$ respectively.

If $$\mathbf{X}$$ and $$\mathbf{Y}$$ are jointly normally distributed,

\mathbf{X}, \mathbf{Y} \sim\ \mathcal{N}(\mathbf\mu, \operatorname{K}), $$ then the conditional distribution for $$\mathbf{Y}$$ given $$\mathbf{X}$$ is given by

\mathbf{Y} \mid \mathbf{X} \sim\ \mathcal{N}(\mathbf{\mu_{Y|X}}, \operatorname{K}_\mathbf{Y|X}), $$ defined by conditional mean

\mathbf{\mu_{Y|X}} = \mathbf{\mu_Y} + \operatorname{K}_\mathbf{YX} \operatorname{K}_\mathbf{XX}^{-1} \left( \mathbf{X} - \mathbf{\mu_X} \right) $$

and conditional variance

\operatorname{K}_\mathbf{Y|X} = \operatorname{K}_\mathbf{YY} - \operatorname{K}_\mathbf{YX} \operatorname{K}_\mathbf{XX}^{-1} \operatorname{K}_\mathbf{XY}. $$

The matrix $$ \operatorname{K}_\mathbf{YX} \operatorname{K}_\mathbf{XX}^{-1} $$ is known as the matrix of regression coefficients, while in linear algebra $$ \operatorname{K}_\mathbf{Y|X} $$ is the Schur complement of $$ \operatorname{K}_\mathbf{XX} $$ in $$ \mathbf\Sigma $$.

The matrix of regression coefficients may often be given in transpose form, $$ \operatorname{K}_\mathbf{XX}^{-1} \operatorname{K}_\mathbf{XY} $$, suitable for post-multiplying a row vector of explanatory variables $$ \mathbf{X}^{\rm T} $$ rather than pre-multiplying a column vector $$ \mathbf{X} $$. In this form they correspond to the coefficients obtained by inverting the matrix of the normal equations of ordinary least squares (OLS).

Partial covariance matrix
A covariance matrix with all non-zero elements tells us that all the individual random variables are interrelated. This means that the variables are not only directly correlated, but also correlated via other variable indirectly. Often such indirect, common-mode correlations are trivial and uninteresting. They can be suppressed by calculating the partial covariance matrix, that is the part of covariance matrix that shows only the interesting part of correlations.

If two vectors of random variables $$\mathbf{X}$$ and $$\mathbf{Y}$$ are correlated via another vector $$\mathbf{I}$$, the latter correlations are suppressed in a matrix

\operatorname{K}_\mathbf{XY \mid I} = \operatorname{pcov}(\mathbf{X},\mathbf{Y} \mid \mathbf{I}) = \operatorname{cov}(\mathbf{X},\mathbf{Y}) - \operatorname{cov}(\mathbf{X},\mathbf{I}) \operatorname{cov}(\mathbf{I},\mathbf{I})^{-1} \operatorname{cov}(\mathbf{I},\mathbf{Y}). $$ The partial covariance matrix $$\operatorname{K}_\mathbf{XY \mid I}$$ is effectively the simple covariance matrix $$\operatorname{K}_\mathbf{XY}$$ as if the uninteresting random variables $$\mathbf{I}$$ were held constant.

Covariance matrix as a parameter of a distribution
If a column vector $$ \mathbf{X} $$ of $$ n $$ possibly correlated random variables is jointly normally distributed, or more generally elliptically distributed, then its probability density function $$ \operatorname{f}(\mathbf{X}) $$ can be expressed in terms of the covariance matrix $$ \mathbf{\Sigma} $$ as follows

\operatorname{f}(\mathbf{X}) = (2 \pi)^{-n/2} |\mathbf{\Sigma}|^{-1/2} \exp \left ( - \tfrac{1}{2} \mathbf{(X - \mu)^{\rm T} \Sigma^{-1} (X - \mu)} \right ), $$ where $$ \mathbf{\mu = \operatorname{E}[X]} $$ and $$ |\mathbf{\Sigma}| $$ is the determinant of $$ \mathbf{\Sigma} $$.

Sections to insert at the end of Covariance matrix#Applications

Covariance mapping
In covariance mapping the values of the $$ \operatorname{cov}(\mathbf{X}, \mathbf{Y}) $$ or $$ \operatorname{pcov}(\mathbf{X}, \mathbf{Y} \mid \mathbf{I}) $$ matrix are plotted as a 2-dimensional map. When vectors $$ \mathbf{X} $$ and $$ \mathbf{Y} $$ are discrete random functions, the map shows statistical relations between different regions of the random functions. Statistically independent regions of the functions show up on the map as zero-level flatland, while positive or negative correlations show up, respectively, as hills or valleys.

In practice the column vectors $$ \mathbf{X}, \mathbf{Y} $$, and $$ \mathbf{I} $$ are acquired experimentally as rows of $$ n $$ samples, e.g.
 * $$ [\mathbf{X}_1, \mathbf{X}_2, ... \mathbf{X}_n] =

\begin{bmatrix} X_1(t_1) & X_2(t_1) & \cdots & X_n(t_1) \\ \\ X_1(t_2) & X_2(t_2) & \cdots & X_n(t_2) \\ \\ \vdots  &   \vdots & \ddots & \vdots   \\ \\ X_1(t_m) & X_2(t_m) & \cdots & X_n(t_m) \end{bmatrix} , $$ where $$ X_j(t_i) $$ is the i-th descrete value in sample j of the random function $$ X(t) $$. The expected values needed in the covariance formula are estimated using the sample mean, e.g.
 * $$ \langle \mathbf{X} \rangle = \frac{1}{n} \sum^{n}_{j=1} \mathbf{X}_j $$

and the covariance matrix is estimated by the sample covariance matrix

\operatorname{cov}(\mathbf{X},\mathbf{Y}) \approx \langle \mathbf{XY^{\rm T}} \rangle - \langle \mathbf{X} \rangle \langle \mathbf{Y}^{\rm T} \rangle , $$ where the angular brackets denote sample averaging as before except that the Bessel's correction should be made to avoid bias. Using this estimation the partial covariance matrix can be calculated as

\operatorname{pcov}(\mathbf{X},\mathbf{Y} \mid \mathbf{I}) = \operatorname{cov}(\mathbf{X},\mathbf{Y}) - \operatorname{cov}(\mathbf{X},\mathbf{I}) \left (   \operatorname{cov}(\mathbf{I},\mathbf{I})  \backslash \operatorname{cov}(\mathbf{I},\mathbf{Y}) \right ), $$ where the backslash denotes the left matrix division operator, which bypasses the requirement to invert a matrix and is available in some computational packages such as Matlab.

Fig. 1 illustrates how a partial covariance map is constructed on an example of an experiment performed at the FLASH free-electron laser in Hamburg. The random function $$ X(t) $$ is the time-of-flight spectrum of ions from a Coulomb explosion of nitrogen molecules multiply ionised by a laser pulse. Since only a few hundreds of molecules are ionised at each laser pulse, the single-shot spectra are highly fluctuating. However, collecting typically $$ m=10^4 $$ such spectra, $$ \mathbf{X}_j(t) $$, and averaging them over $$ j $$ produces a smooth spectrum $$ \langle \mathbf{X}(t) \rangle $$, which is shown in red at the bottom of Fig. 1. The average spectrum $$ \langle \mathbf{X} \rangle $$ reveals several nitrogen ions in a form of peaks broadened by their kinetic energy, but to find the correlations between the ionisation stages and the ion momenta requires calculating a covariance map.

In the example of Fig. 1 spectra $$ \mathbf{X}_j(t) $$ and $$ \mathbf{Y}_j(t) $$ are the same, except that the range of the time-of-flight $$ t $$ differs. Panel a shows $$ \langle \mathbf{XY^{\rm T}} \rangle $$, panel b shows $$ \langle \mathbf{X} \rangle \langle \mathbf{Y^{\rm T}} \rangle $$ and panel c shows their difference, which is $$ \operatorname{cov}(\mathbf{X},\mathbf{Y}) $$ (note a change in the colour scale). Unfortunately, this map is overwhelmed by uninteresting, common-mode correlations induced by laser intensity fluctuating from shot to shot. To suppress such correlations the laser intensity $$ I_j $$ is recorded at every shot, put into $$ \mathbf{I} $$ and $$ \operatorname{pcov}(\mathbf{X},\mathbf{Y} \mid \mathbf{I}) $$ is calculated as panels d and e show. The suppression of the uninteresting correlations is, however, imperfect because there are other sources of common-mode fluctuations than the laser intensity and in principle all these sources should be monitored in vector $$ \mathbf{I} $$. Yet in practice it is often sufficient to overcompensate the partial covariance correction as panel f shows, where interesting correlations of ion momenta are now clearly visible as straight lines centred on ionisation stages of atomic nitrogen.

Two-dimensional infrared spectroscopy
Two-dimensional infrared spectroscopy employs correlation analysis to obtain 2D spectra of the condensed phase. There are two versions of this analysis: synchronous and asynchronous. Mathematically, the former is expressed in terms of the sample covariance matrix and the technique is equivalent to covariance mapping.