def poisson_dist(p1, p2):
    """
    Calculates the Poisson distance between two vectors.

    p1 can be a sparse matrix, while p2 has to be a dense matrix.
    """
    # ugh...
    p1_ = p1 + eps
    p2_ = p2 + eps
    return np.dot(p1_-p2_, np.log(p1_/p2_))