Ejemplo n.º 1
0
def ipareto(prob, lam, xm=1.0):
    """
    The inverse of the Pareto distribution: 
    f = lam * xm**lam / x**(lam+1) 
    F = 1 - (xm/x)**lam
    x in [xm, inf)
    lam > 0
    For lam < 1 all moments are infinite
    For lam < 2 all moments are infinite except for the mean
    """

    _assertprob(prob, 'ipareto')
    assert lam >  0.0, "shape parameter lambda in ipareto must be positive!"
    assert xm  >= 0.0, \
          "left support limit parameter xm must not be negative in ipareto!"

    q  =  1.0 - prob

    if q == 0.0: return float('inf')
    
    x  =  xm * safepow(q, -1.0/lam)

    x  =  kept_within(xm, x)

    return x
Ejemplo n.º 2
0
def ipareto_zero(prob, lam, xm=1.0):
    """
    The inverse of the Pareto distribution with the support shifted to [0, inf):
    f = lam * xm**lam / (x+xm)**(lam+1)
    F = 1 - [xm/(x+xm)]**lam
    x in [0, inf)
    lam > 0
    For lam < 1 all moments are infinite
    For lam < 2 all moments are infinite except for the mean
    """

    _assertprob(prob, 'ipareto_zero')
    assert lam > 0.0, "shape parameter lambda in ipareto_zero must be positive!"
    textxm1 = "left support limit parameter xm of unshifted in ipareto_zero"
    textxm2 = "distribution must not be negative in ipareto_zero!"
    assert xm  >= 0.0, textxm1 + textxm2

    q  =  1.0 - prob

    if q == 0.0: return float('inf')

    x  =  xm * (safepow(q, -1.0/lam) - 1.0)

    x  =  kept_within(0.0, x)

    return x
Ejemplo n.º 3
0
def iweibull(prob, c, scale=1.0):
    """
    The inverse of the Weibull distribution:
    F = 1 - exp[-(x/s)**c]
    x >= 0, s >= 0, c >= 1 
    """

    if c == 1.0:
        x = iexpo(prob, scale)

    else:
        _assertprob(prob, 'iweibull')
        # ---
        assert   c   >= 1.0, \
                   "shape parameter in iweibull must not be smaller than 1.0!"
        assert scale >= 0.0, "scale parameter in iweibull must not be negative!"

        x  =  scale * safepow(-safelog(1.0-prob), 1.0/c)

        #x  =  kept_within(0.0, x)  # Not really needed

    return x