예제 #1
0
 def _fifi2fid(x):
     x      = kept_within(0.0, x)
     cdf    = cerlang(nshape, phasemean, x)
     pdf    = derlang(nshape, phasemean, 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 rerlang(self, nshape, phasemean, xmax=float('inf'), pmax=1.0):  
        """
        Generator of Erlang-distributed random variates.
        Represents the sum of nshape exponentially distributed random variables, 
        each having the same mean value = phasemean. For nshape = 1 it works as 
        a generator of exponentially distributed random numbers.
        """

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

        pmx = pmax
        if xmax < float('inf'):
            pmx = min(pmax, cerlang(nshape, phasemean, xmax))

        p  =  pmx * self.runif01()
        x = ierlang(p, nshape, phasemean)

        return x