Beispiel #1
0
 def _fifi2fid(x):
     x      = kept_within(0.0, x)
     cdf    = cfoldednormal(muunfold, sigmaunfold, x)
     pdf    = dfoldednormal(muunfold, sigmaunfold, 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
Beispiel #2
0
    def rfoldednormal(self, muunfold, sigmaunfold, xmax=float('inf'), pmax=1.0):
        """
        The distribution of a random variable that is the absolute value
        of a variate drawn from the normal distribution (i. e. the distribution 
        of a variate that is the absolute value of a normal variate, the latter 
        having muunfold as its mean and sigmaunfold as its standard deviation). 
        
        sigmaunfold >= 0.0
        """

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

        pmx = pmax
        if xmax < float('inf'): \
                 pmx = min(pmax, cfoldednormal(muunfold, sigmaunfold, xmax))

        p  =  pmx * self.runif01()
        x  =  ifoldednormal(p, muunfold, sigmaunfold)

        return x