Example #1
0
    def rcoxian2(self, means, probs, xmax=float('inf'), pmax=1.0):
        """
        Generates a random number from the Coxian phased distribution, which is 
        based on the exponential.
        probs is a list of probabilities for GOING ON TO THE NEXT PHASE rather 
        than 
        reaching the absorbing state prematurely. The number of means must (of 
        course) be one more than the number of probabilities!
        
        NB No two means must be equal - if this is desired, use rcoxian instead! 
        
        NB It is better to use rNexpo2 when all probs=1.0 ! 

        """

        assert xmax >= 0.0, "xmax must be a non-negative float in rcoxian2!"
        self._checkpmax(pmax, 'rcoxian2')

        pmx = pmax
        if xmax < float('inf'): pmx = min(pmax, ccoxian2(means, probs, xmax))

        p  =  pmx * self.runif01()
        x  =  icoxian2(p, means, probs)

        return x
Example #2
0
 def _fifi2fid(x):
     x      = kept_within(0.0, x)
     cdf    = ccoxian2(means, probs, x)
     pdf    = dcoxian2(means, probs, x)
     fi     = cdf - prob
     if pdf <= 0.0:
         if fi == 0.0: fi2fid = 1.0
         else:         fi2fid = MAXFLOAT
     else:
         fi2fid = fi/pdf
     return fi, fi2fid