def _fifi2fid(x): x = kept_within(0.0, x) cdf = ccoxian(means, probs, x) pdf = dcoxian(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
def rcoxian(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 means are allowed to be equal! NB It is better to use rNexpo when all probs=1.0 ! """ assert xmax >= 0.0, "xmax must be a non-negative float in rcoxian!" self._checkpmax(pmax, 'rcoxian') pmx = pmax if xmax < float('inf'): pmx = min(pmax, ccoxian(means, probs, xmax)) p = pmx * self.runif01() x = icoxian(p, means, probs) return x