CovarianceToyMC

Description

Generates a random sample distributed according to multivariate normal distribution.

Uses boost::mt19937 random generator.

The sample becomes frozen upon generation. One has to manually taint the transformation for the next sample by calling nextSample method.

Limitations

Be careful with generatining random numbers with high level of correlation. Presence of correlation coefficients of order of 0.9 will most likely cause the distribution width to be invalid. So test the generator prior the actual usage.

Inputs

  1. Average model vector \(\mu_1\).

  2. First model covariance matrix \(V_1\) Cholesky decomposition \(L_1\).

  3. Average model vector \(\mu_2\).

  4. Second model covariance matrix \(V_2\) Cholesky decomposition \(L_2\).

  5. etc.

  6. etc.

Inputs are added via add(theory, cov) method.

Outputs

  1. 'toymc' — output vector \(x\) of size of concatination of \(\mu_i\).

Tests

Use the following commands for the usage example and testing:

./tests/elementary/test_random_transformations.py -n 100000 -o output/random.pdf

Implementation

For the random variable vector \(x\) of size \(N\), distributed around \(\mu\) with covariance matrix \(V\) the p.d.f. is:

\[P(x|\mu) = \frac{1}{\sqrt{ (2\pi)^N |V| }} e^{\frac{1}{2} \displaystyle(x-\mu)^T V^{-1} (x-\mu) }.\]

For the decomposed covariance matrix \(V=LL^T\) the exponent power reads:

\[\left((x-\mu) L^{-1}\right)^T L^{-1} (x-\mu).\]

One can define the variable \(z\):

\[\begin{split}&z = L^{-1} (x-\mu),\\ &x = Lz + \mu.\end{split}\]

Since the transition Jacobian \(|dx/dz|=|L|=\sqrt{|V|}\) each \(z_i\) is distributed normally with \(\sigma=1\) with central value of \(0\).

The algorithm generates normal vector \(z\) and transforms it to \(x=Lz + \mu\).

By \(\mu\) we mean the concatenation of vectors \(\mu_i\).