netrd/reconstruction/mutual_information_matrix.py
def threshold_from_degree(deg,M):
    """
    Compute the required threshold (tau) in order to yield a reconstructed graph of mean degree deg.
    Params
    ------
    deg (int): Target degree for which the appropriate threshold will be computed
    M (np.ndarray): Pre-thresholded NxN array
    Returns
    ------
    tau (float): Required threshold for A=np.array(I<tau,dtype=int) to have an average of deg ones per row/column

    """
    N=len(M)
    A=np.ones((N,N)) # start with a complete graph (lowest possible threshold)
    for tau in sorted(M.flatten()): # consider increasingly large entry-values
        A[M==tau]=0 # remove edges of weight less than the current entry
        if np.mean(np.sum(A,1))<deg: # stop once the matrix is trimmed down to mean degree deg
            break
    return tau

    Compute the required threshold (tau) in order to yield a reconstructed graph of mean degree deg.
    Params
    ------
    deg (int): Target degree for which the appropriate threshold will be computed
    M (np.ndarray): Pre-thresholded NxN array
    Returns
    ------
    tau (float): Required threshold for A=np.array(I<tau,dtype=int) to have an average of deg ones per row/column

    
Compute the required threshold (tau) in order to yield a reconstructed graph of mean degree deg.
Params

deg (int): Target degree for which the appropriate threshold will be computed
M (np.ndarray): Pre-thresholded NxN array
Returns

tau (float): Required threshold for A=np.array(I<tau,dtype=int) to have an average of deg ones per row/column
Compute the required threshold ( tau ) in order to yield a reconstructed graph of mean degree deg . Params deg ( int ) : Target degree for which the appropriate threshold will be computed M ( np . ndarray ) : Pre - thresholded NxN array Returns tau ( float ) : Required threshold for A = np . array ( I<tau dtype = int ) to have an average of deg ones per row / column
def threshold_from_degree(deg,M):
    N=len(M)
    A=np.ones((N,N)) 
    for tau in sorted(M.flatten()): 
        A[M==tau]=0 
        if np.mean(np.sum(A,1))<deg: 
            break
    return tau
def threshold_from_degree ( deg , M ) : N = len ( M ) A = np . ones ( ( N , N ) ) for tau in sorted ( M . flatten ( ) ) : A [ M == tau ] = 0 if np . mean ( np . sum ( A , 1 ) ) < deg : break return tau
Compute the required threshold (tau) in order to yield a reconstructed graph of mean degree deg.
Compute the required threshold ( tau ) in order to yield a reconstructed graph of mean degree deg .
"""
    Compute the required threshold (tau) in order to yield a reconstructed graph of mean degree deg.
    Params
    ------
    deg (int): Target degree for which the appropriate threshold will be computed
    M (np.ndarray): Pre-thresholded NxN array
    Returns
    ------
    tau (float): Required threshold for A=np.array(I<tau,dtype=int) to have an average of deg ones per row/column

    """ # start with a complete graph (lowest possible threshold) # consider increasingly large entry-values # remove edges of weight less than the current entry # stop once the matrix is trimmed down to mean degree deg
deg
M