src/fisher.cpp
// pcond1 is a matrix of probabilities p(I and k), where "I and k" refers to states with
// leaf state I and compatible with k.
// rows in pcond1 are indexed by leaf states. Columns are indexed by a linear index encoding
// a free parameter.
pcond1 is a matrix of probabilities p(I and k), where "I and k" refers to states with
leaf state I and compatible with k.
rows in pcond1 are indexed by leaf states. Columns are indexed by a linear index encoding
a free parameter.
pcond1 is a matrix of probabilities p ( I and k ) where " I and k " refers to states with leaf state I and compatible with k . rows in pcond1 are indexed by leaf states . Columns are indexed by a linear index encoding a free parameter .
void fill_pcond1(Tree &T, Model &Mod, StateList &sl, Parameters &Par, Array2 &pcond1) {
  long i,j,l,u,v;
  long k,e,a,b;
  double p;
  long npars = T.nedges*Mod.np + Mod.rdf + 1;
  pcond1.resize(T.nstleaves);
  for (i=0; i < T.nstleaves; i++) {
    pcond1[i].resize(npars);
    for(k=0; k < npars; k++) {
      pcond1[i][k] = 0;
    }
  }
  for (i=0; i < T.nstleaves; i++) {
    for(j=0; j < T.nsthidden; j++) {
      for(e=0; e < T.nedges; e++) {
        p = Par.r[rootstate(sl.h[j])];
        for(l=0; l < T.nedges; l++) {
          if (l == e) continue;
          edgestate(T, l, sl.h[j], sl.l[i], u, v);
          p = p*Par.tm[l][u][v];
        }
        edgestate(T, e, sl.h[j], sl.l[i], a, b);
        k = erc2param(Mod, e, a, b);
        pcond1[i][k] = pcond1[i][k] + p;
      }
      p = 1;
      for(l=0; l < T.nedges; l++) {
        edgestate(T, l, sl.h[j], sl.l[i], u, v);
        p = p*Par.tm[l][u][v];
      }
      k = root2param(T, Mod, rootstate(sl.h[j]));
      pcond1[i][k] = pcond1[i][k] + p;
    }
  }
}
void fill_pcond1 ( Tree & T , Model & Mod , StateList & sl , Parameters & Par , Array2 & pcond1 ) { long i , j , l , u , v ; long k , e , a , b ; double p ; long npars = T . nedges * Mod . np + Mod . rdf + 1 ; pcond1 . resize ( T . nstleaves ) ; for ( i = 0 ; i < T . nstleaves ; i ++ ) { pcond1 [ i ] . resize ( npars ) ; for ( k = 0 ; k < npars ; k ++ ) { pcond1 [ i ] [ k ] = 0 ; } } for ( i = 0 ; i < T . nstleaves ; i ++ ) { for ( j = 0 ; j < T . nsthidden ; j ++ ) { for ( e = 0 ; e < T . nedges ; e ++ ) { p = Par . r [ rootstate ( sl . h [ j ] ) ] ; for ( l = 0 ; l < T . nedges ; l ++ ) { if ( l == e ) continue ; edgestate ( T , l , sl . h [ j ] , sl . l [ i ] , u , v ) ; p = p * Par . tm [ l ] [ u ] [ v ] ; } edgestate ( T , e , sl . h [ j ] , sl . l [ i ] , a , b ) ; k = erc2param ( Mod , e , a , b ) ; pcond1 [ i ] [ k ] = pcond1 [ i ] [ k ] + p ; } p = 1 ; for ( l = 0 ; l < T . nedges ; l ++ ) { edgestate ( T , l , sl . h [ j ] , sl . l [ i ] , u , v ) ; p = p * Par . tm [ l ] [ u ] [ v ] ; } k = root2param ( T , Mod , rootstate ( sl . h [ j ] ) ) ; pcond1 [ i ] [ k ] = pcond1 [ i ] [ k ] + p ; } } }
pcond1 is a matrix of probabilities p(I and k), where "I and k" refers to states with
leaf state I and compatible with k.
rows in pcond1 are indexed by leaf states.
pcond1 is a matrix of probabilities p ( I and k ) where " I and k " refers to states with leaf state I and compatible with k . rows in pcond1 are indexed by leaf states .
// Initializations // Loop over all states // Loop over edges // Compute cond1 probabilities // Take care of root parameters in pcond1