max_ll_util.h.html mathcode2html   
 Source file:   max_ll_util.h
 Converted:   Sat May 9 2015 at 14:44:17
 This documentation file will not reflect any later changes in the source file.

$$\phantom{******** If you see this on the webpage then the browser could not locate *********}$$
$$\phantom{******** jsMath/easy/load.js or the variable root is set wrong in this file *********}$$
$$\newcommand{\vector}[1]{\left[\begin{array}{c} #1 \end{array}\right]}$$ $$\newenvironment{matrix}{\left[\begin{array}{cccccccccc}} {\end{array}\right]}$$ $$\newcommand{\A}{{\cal A}}$$ $$\newcommand{\W}{{\cal W}}$$

/* Copyright 2008-2011 Research Foundation State University of New York   */

/* This file is part of QUB Express.                                      */

/* QUB Express is free software; you can redistribute it and/or modify    */
/* it under the terms of the GNU General Public License as published by   */
/* the Free Software Foundation, either version 3 of the License, or      */
/* (at your option) any later version.                                    */

/* QUB Express is distributed in the hope that it will be useful,         */
/* but WITHOUT ANY WARRANTY; without even the implied warranty of         */
/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the          */
/* GNU General Public License for more details.                           */

/* You should have received a copy of the GNU General Public License,     */
/* named LICENSE.txt, in the QUB Express program directory.  If not, see  */
/* <http://www.gnu.org/licenses/>.                                        */

#ifndef MAX_LL_UTIL_H
#define MAX_LL_UTIL_H

#include "ublas_plus.h"

/*

This unit provides common functions for MIL and MSL

See also:

Up: Index

*/

/*
The Q matrix of rate constants (probability per second) is computed from intrinsic rate constants K0 and K1, and potentially Ligand- and Voltage-sensitive. \[Q_{a,b} = K0_{a,b} * Ligand_{a,b} * e^{K1_{a,b} * Voltage_{a,b}}\] \[Q_{a,a} = - \sum_i Q_{a,i}\]
*/
QUBFAST_API void BuildQ(int Ns, matrix<double>& Q, matrix<double>& K0, matrix<double>& K1, matrix<int>& Ligand, matrix<int>& Voltage, double *Constants);
QUBFAST_API void BuildQ_p(int Ns, matrix<double>& Q, matrix<double>& K0, matrix<double>& K1, matrix<double>& K2, matrix<int>& Ligand, matrix<int>& Voltage, matrix<int>& Pressure, double *Constants);

/*
"Qe" aka \({}^eQ\) is the "apparent" rate constant matrix, given that events with duration <= tdead are not recorded. MIL and MSL compute the probability of staying in class a for duration t using the submatrix \({}^eQ_{aa}\) \[A(a, t) = e^{{}^eQ_{aa} t'}\]
*/
QUBFAST_API void QtoQe(matrix<double>& Q, int *clazz, double tdead, matrix<double>& eQ);

/*

As discussed in (Milescu 2005), it can be preferable to start an experiment at equilibrium. Entry probabilities (P0) are then no longer constant, but a function of rate constants. We use the "direct" method given in Neher and Sakmann:

Defining \(S = [Q | 1]\) and \(u\) a row vector of ones, \[P_{eq} = u \cdot (S \cdot S^T)^{-1}\]

*/
QUBFAST_API void QtoPe(matrix<double>& Q, matrix<double>& Pe);


/*

As discussed in (Qin 1997), the forward probability vectors alpha must be frequently rescaled to 1 in order to stay within machine precision. Conveniently, the log likelihood is the sum of these log scaling factors.

*/
QUBFAST_API double alpha_logscale(vector<double>& alpha);


#endif