def METHOD_NAME(rng, x1, x2, n):
    """Generate a random value drawn from a power law distribution.
    Assume power law between x1 and x2
    p(x)  = A x^n
    Generate by taking cdf = rng() (uniform from 0..1)
    """
    cdf = rng()
    if n == -1:
        # cdf = A exp(x/x1)
        # cdf = ln(f/x1) / ln(x2/x1)
        f = x1 * np.exp(cdf * np.log(x2/x1))
    else:
        # cdf = A/(n+1) (x^(n+1) - x1^(n+1))
        #     = (f^(n+1) - x1^(n+!) / (x2^(n+1) - x1^(n+1))
        f1 = x1**(n+1)
        f2 = x2**(n+1)
        f = (cdf * (f2-f1) + f1)**(1./(n+1))
    return f