Esempio n. 1
0
 def _fifi2fid(x):
     x      = kept_within(0.0, x)
     cdf    = cerlang_gen(nshapes, qumul, phasemean, x)
     pdf    = derlang_gen(nshapes, qumul, 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
Esempio n. 2
0
    def rerlang_gen(self, nshapes, qumul, phasemean, \
                          xmax=float('inf'), pmax=1.0):
        """
        The generalized Erlang distribution - the Erlang equivalent of the 
        rhyperexpo generator 
        f = sumk pk * ferlang(m, nk), F = sumk pk * Ferlang(m, nk), the same
        mean for all phases.
        
        NB Input to the function is the list of CUMULATIVE FREQUENCIES ! 
        """

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

        pmx = pmax
        if xmax < float('inf'): \
               pmx = min(pmax, cerlang_gen(nshapes, qumul, phasemean, xmax))

        p  =  pmx * self.runif01()
        x  =  ierlang_gen(p, nshapes, qumul, phasemean)

        return x