extend_dirichlet(p)

    Concatenates 1-sum(p) to the end of p and returns.

def extend_dirichlet(p):
    """
    extend_dirichlet(p)

    Concatenates 1-sum(p) to the end of p and returns.
    """
    if len(np.shape(p)) > 1:
        return np.hstack((p, np.atleast_2d(1. - np.sum(p))))
    else:
        return np.hstack((p, 1. - np.sum(p)))