Ejemplo n.º 1
0
def i_nToKlinages(n, k, p, t) :
  """ Probability of k remaining lineages from n after time t and population
  integrated over the prior p (hardwired to inv gamma at the moment, should be
  more general)"""
  
  a,b = p.alpha,p.beta
  ix = lambda x : (b/(b + x))**a
  civ = ci(n,k)
  assert len(civ) == n-k+1, (n,k,len(civ),civ, ci(n,k)) 
  return sum([civ[i-k] * ix(c2(i)*t) for i in range(k, n+1)])
Ejemplo n.º 2
0
def nToKlinages(n, k, d, t) :
  """ Probability of k remaining lineages from n after time t and population
  size function d"""
  
  return sum([c_t(n,k,i) * exp(-c2(i) * d.integrate(t)) for i in range(k, n+1)])
Ejemplo n.º 3
0
def nForestRankedTopologies(n1, n2, k) :
  """ Number of ranked histories of a labeled forest with 1+k trees, the
  first tree on n1 taxa, the remaining k on a total of n2 taxa.
  """
  
  return choose(n1+n2-k-2, n1-2) * prod([long(c2(x)) for x in range(3, n1+1) + range(k+1, n2+1)])
Ejemplo n.º 4
0
def nLabeledHistories(n, k=1) :
  """ Total number of ranked histories of (labeled) k-forests with total of
  n tips.""" 
  assert n >= k
  
  return prod([long(c2(x)) for x in range(n, k, -1)])