Ideal transition densities \(\mathcal{G}(t)\)¶
A wrapper around QMatrix is provided which allows the calculation of
the ideal transition densities:
This object can be initialized directly from a QMatrix.
- Python:
from HJCFIT.likelihood import QMatrix, IdealG, expm qmatrix = QMatrix([ [-3050, 50, 3000, 0, 0], [2./3., -1502./3., 0, 500, 0], [ 15, 0, -2065, 50, 2000], [ 0, 15000, 4000, -19000, 0], [ 0, 0, 10, 0, -10] ], 2) idealG = IdealG(qmatrix) print(idealG)
- C++11:
#include <iostream> #include <exception> #include <likelihood/idealG.h> #include <likelihood/errors.h> int main() { // Define parameters. HJCFIT::t_rmatrix matrix(5 ,5); matrix << -3050, 50, 3000, 0, 0, 2./3., -1502./3., 0, 500, 0, 15, 0, -2065, 50, 2000, 0, 15000, 4000, -19000, 0, 0, 0, 10, 0, -10; HJCFIT::QMatrix qmatrix(matrix, /*nopen=*/2); HJCFIT::IdealG idealG(qmatrix); std::cout << idealG << std::endl; return 0; }
It provides the ideal likelihood as a function of time, as well as the Laplace transforms:
- Python:
from numpy import dot, identity, abs, all idealG_fa = dot(expm(2e-4 * qmatrix.ff), qmatrix.fa) assert all( abs(idealG_fa - idealG.fa(2e-4)) < 1e-8 ) inversion = -0.5 * identity(2) - qmatrix.aa assert all( abs( dot(inversion, idealG.laplace_af(-0.5)) - qmatrix.af ) < 1e-8 )
Note
This package can be compiled to use long doubles. However, despite providing arrays for reals of that size, numpy does not include the corresponding linear algebra functions. A few useful functions, such as
expmin this example, are provided to remediate to this situation.- C++11:
HJCFIT::t_rmatrix const idealG_fa = (2e-4*qmatrix.ff()).exp()*qmatrix.fa(); if( ((idealG.fa(2e-4) - idealG_fa).array().abs() > 1e-8).any() ) throw HJCFIT::errors::Runtime("Not so ideal idealG"); HJCFIT::t_rmatrix const inversion = -0.5 * HJCFIT::t_rmatrix::Identity(2, 2) - qmatrix.aa(); if( ((inversion * idealG.laplace_af(-0.5) - qmatrix.af()).array().abs() > 1e-8).any() ) throw HJCFIT::errors::Runtime("Not so ideal idealG");