def _fifi2fid(x): x = kept_within(0.0, x) cdf = cNexpo(means, x) pdf = dNexpo(means, 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 rNexpo(self, means, xmax=float('inf'), pmax=1.0): """ Generator of random variates from a distribution of the sum of exponentially distributed random variables. means[k] = 1.0/lambda[k]. NB Numbers in the means vector can be exactly equal! This generator is slow, however... """ assert xmax >= 0.0, "xmax must be a non-negative float in rNexpo!" self._checkpmax(pmax, 'rNexpo') pmx = pmax if xmax < float('inf'): pmx = min(pmax, cNexpo(means, xmax)) p = pmx * self.runif01() x = iNexpo(p, means) return x