def plexp_cdf(x,xmin=1,alpha=2.5, pl_only=False, exp_only=False):
    """
    CDF(x) for the piecewise distribution exponential x<xmin, powerlaw x>=xmin
    This is the CDF version of the distributions drawn in fig 3.4a of Clauset et al.
    The constant "C" normalizes the PDF
    """

    x = np.array(x)
    C = 1/(-xmin/(1 - alpha) - xmin/alpha + exp(alpha)*xmin/alpha)
    Ppl = lambda X: 1+C*(xmin/(1-alpha)*(X/xmin)**(1-alpha))
    Pexp = lambda X: C*xmin/alpha*exp(alpha)-C*(xmin/alpha)*exp(-alpha*(X/xmin-1))

    if exp_only:
        return Pexp(x)
    elif pl_only:
        return Ppl(x)

    d=Ppl(x)
    d[x<xmin]=Pexp(x)[x<xmin]
    return d