def sparsity(A):
    """The marginal probability for a connection

    Parameters
    ----------
    A : 2d-array
        Binary adjacency matrix.

    Returns
    -------
    p : float
        The marginal probability for a connection (network sparsity).

    See Also
    --------
    reciprocity

    """
    assert len(A.shape) == 2 and A.shape[0] == A.shape[1]
    n = A.shape[0]
    return A.sum() / float(n * (n - 1))
