private final double conditionalSurvivalProbability(int x,double v,int y,double t,double[] m){
  double mt=m[0] + m[1];
  if (v < 0 || v > t) {
    throw new IllegalArgumentException("v must be non-negative and not exceed t\n v=" + v + " t="+ t);
  }
 else {
    double a, b, c, d;
    if (x == y) {
      a=m[0] * m[1];
      b=-a;
      c=m[1 - x];
      d=m[x];
    }
 else {
      a=m[1 - y];
      b=m[1 - x];
      c=1;
      d=-1;
    }
    double exponent=(b * c - a * d) / (c * d * -mt);
    double C=Math.pow(c * Math.exp(-mt * t) + d,-exponent);
    return C * Math.exp(b * v / d) * Math.pow(d + c * Math.exp(-mt * (t - v)),exponent);
  }
}

private final double conditionalSurvivalProbability ( int x , double v , int y , double t , double [ ] m ) { double mt = m [ 0 ] + m [ 1 ] ; if ( v < 0 || v > t ) { throw new IllegalArgumentException ( "v must be non-negative and not exceed t\n v=" + v + " t=" + t ) ; } else { double a , b , c , d ; if ( x == y ) { a = m [ 0 ] * m [ 1 ] ; b = - a ; c = m [ 1 - x ] ; d = m [ x ] ; } else { a = m [ 1 - y ] ; b = m [ 1 - x ] ; c = 1 ; d = - 1 ; } double exponent = ( b * c - a * d ) / ( c * d * - mt ) ; double C = Math . pow ( c * Math . exp ( - mt * t ) + d , - exponent ) ; return C * Math . exp ( b * v / d ) * Math . pow ( d + c * Math . exp ( - mt * ( t - v ) ) , exponent ) ; } }
pr ( t > v | x , y , t ) the probability of surviving until time v without migrating , conditional on starting in state x at time 0 and being in state y at time t .
