plfit/plfit.py
def plexp_inv(P, xmin, alpha, guess=1.):
    """
    Inverse CDF for a piecewise PDF as defined in eqn. 3.10
    of Clauset et al.

    (previous version was incorrect and lead to weird discontinuities in the
    distribution function)
    """
    def equation(x,prob):
        return plexp_cdf(x, xmin, alpha)-prob
    # http://stackoverflow.com/questions/19840425/scipy-optimize-faster-root-finding-over-2d-grid
    def solver(y, x0=guess):
        return scipy.optimize.fsolve(equation, guess, args=(y,))
    f = np.vectorize(solver)
    return f(P)
def plexp_inv(P, xmin, alpha, guess=1.):
    """
    Inverse CDF for a piecewise PDF as defined in eqn. 3.10
    of Clauset et al.

    (previous version was incorrect and lead to weird discontinuities in the
    distribution function)
    """
    def equation(x,prob):
        return plexp_cdf(x, xmin, alpha)-prob
    # http://stackoverflow.com/questions/19840425/scipy-optimize-faster-root-finding-over-2d-grid
    def solver(y, x0=guess):
        return scipy.optimize.fsolve(equation, guess, args=(y,))
    f = np.vectorize(solver)
    return f(P)
def plexp_inv ( P , xmin , alpha , guess = 1. ) : def equation ( x , prob ) : return plexp_cdf ( x , xmin , alpha ) - prob # http://stackoverflow.com/questions/19840425/scipy-optimize-faster-root-finding-over-2d-grid def solver ( y , x0 = guess ) : return scipy . optimize . fsolve ( equation , guess , args = ( y , ) ) f = np . vectorize ( solver ) return f ( P )
Inverse CDF for a piecewise PDF as defined in eqn. 3.10
    of Clauset et al.

    (previous version was incorrect and lead to weird discontinuities in the
    distribution function)
Inverse CDF for a piecewise PDF as defined in eqn . 3 . 10 of Clauset et al .