예제 #1
0
 def _fifi2fid(x):
     x      = kept_within(0.0, x)
     cdf    = cNexpo2(means, x)
     pdf    = dNexpo2(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
예제 #2
0
    def rNexpo2(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 No two numbers in the means vector can be exactly equal! If this 
        is desired, use rNexpo ! 
        """

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

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

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

        return x