Example #1
0
def _dstable_sym_int(alpha, x, tolromb, mxsplromb):
    """
    The integral formulation of the standard pdf (cf. for instance Matsui, M., 
    and Takemura, A., "Some Improvements in Numerical Evaluation of Symmetric 
    Stable Density and its Derivatives", University of Tokyo Report CIRJE-F-292,
    Aug. 2004.
    """

    # Auxiliary functions for calculating the breakpoint
    # (the integration interval is broken up into two portions,
    # cf. Matusi & Takemura) and integral:
    am1 = alpha - 1.0
    aoam1 = alpha / am1

    # -------------
    def _gm1(phi2):
        try:            g = (x*cos(phi2)/sin(alpha*phi2))**(aoam1) * \
                               (cos(am1*phi2)/cos(phi2))
        except ZeroDivisionError:
            g = 0.0
        except OverflowError:
            g = 0.0
        return g - 1.0

    # --------------
    def _func(phi1):
        try:            g = (x*cos(phi1)/sin(alpha*phi1))**(aoam1) * \
                               (cos(am1*phi1)/cos(phi1))
        except ZeroDivisionError:
            g = 0.0
        except OverflowError:
            g = 0.0
        y = exp(-g)
        if y == 0.0:
            z = g - log(g)
            y = exp(-z)
        else:
            y = g * y
        return y

    # --------------

    # Integrate!
    # First find the break point:
    point2 = zbrent(_gm1, MACHEPS, PIHALF, 'dstable_sym/_dstable_sym_int')
    if point2 == ERRCODE: point2 = 0.5 * PIHALF
    # Then perform Romberg quadrature for the
    # two panels separated by the break point:
    pdf  = qromberg(_func,   0.0,  point2, 'dstable_sym/_dstable_sym_int', \
                                            tolromb, mxsplromb)
    pdf += qromberg(_func, point2, PIHALF, 'dstable_sym/_dstable_sym_int', \
                                            tolromb, mxsplromb)
    pdf *= alpha / (PI * abs(am1) * x)

    # Return:
    return pdf
Example #2
0
def _dstable_sym_int(alpha, x, tolromb, mxsplromb):

    """
    The integral formulation of the standard pdf (cf. for instance Matsui, M., 
    and Takemura, A., "Some Improvements in Numerical Evaluation of Symmetric 
    Stable Density and its Derivatives", University of Tokyo Report CIRJE-F-292,
    Aug. 2004.
    """

    # Auxiliary functions for calculating the breakpoint 
    # (the integration interval is broken up into two portions, 
    # cf. Matusi & Takemura) and integral:
    am1   = alpha - 1.0
    aoam1 = alpha/am1
    # -------------
    def _gm1(phi2):
        try: g = (x*cos(phi2)/sin(alpha*phi2))**(aoam1) * \
                                (cos(am1*phi2)/cos(phi2))
        except ZeroDivisionError: g = 0.0
        except OverflowError:     g = 0.0
        return g - 1.0
    # --------------
    def _func(phi1):
        try: g = (x*cos(phi1)/sin(alpha*phi1))**(aoam1) * \
                                (cos(am1*phi1)/cos(phi1))
        except ZeroDivisionError: g = 0.0
        except OverflowError:     g = 0.0
        y = exp(-g)
        if y == 0.0:
            z = g - log(g)
            y = exp(-z)
        else:
            y = g*y
        return y
    # --------------

    # Integrate!
    # First find the break point:
    point2 = zbrent(_gm1, MACHEPS, PIHALF, 'dstable_sym/_dstable_sym_int')
    if point2 == ERRCODE: point2 = 0.5*PIHALF
    # Then perform Romberg quadrature for the 
    # two panels separated by the break point:
    pdf  = qromberg(_func,   0.0,  point2, 'dstable_sym/_dstable_sym_int', \
                                            tolromb, mxsplromb)
    pdf += qromberg(_func, point2, PIHALF, 'dstable_sym/_dstable_sym_int', \
                                            tolromb, mxsplromb)
    pdf *= alpha/(PI*abs(am1)*x)

    # Return:
    return pdf
Example #3
0
def _stable_sym_int(alpha, x, tolromb, mxsplromb):
    """
    Integration of the standard pdf
    (nb a change of integration variable is made!)
    """

    assert alpha < 1.0, "alpha must be < 1.0 in _stable_sym_int!"

    onema = 1.0 - alpha
    oneoonema = 1.0 / onema
    aoonema = alpha * oneoonema

    # -------------------------------------------------------------------------
    def _func(t):
        return dstable_sym(alpha, 0.0, 1.0, pow(t, oneoonema)) * pow(
            t, aoonema)

    # -------------------------------------------------------------------------

    cdf  = oneoonema * qromberg(_func, 0.0, pow(x, onema), \
                            'cstable_sym/_stable_sym_int', tolromb, mxsplromb)
    cdf += 0.5

    cdf = kept_within(0.5, cdf, 1.0)
    return cdf
Example #4
0
def _stable_sym_int(alpha, x, tolromb, mxsplromb):
    """
    Integration of the standard pdf
    (nb a change of integration variable is made!)
    """

    assert alpha < 1.0, "alpha must be < 1.0 in _stable_sym_int!"

    onema = 1.0 - alpha
    oneoonema = 1.0 / onema
    aoonema = alpha * oneoonema

    # -------------------------------------------------------------------------
    def _func(t):
        return dstable_sym(alpha, 0.0, 1.0, pow(t, oneoonema)) * pow(t, aoonema)

    # -------------------------------------------------------------------------

    cdf = oneoonema * qromberg(_func, 0.0, pow(x, onema), "cstable_sym/_stable_sym_int", tolromb, mxsplromb)
    cdf += 0.5

    cdf = kept_within(0.5, cdf, 1.0)
    return cdf