netrd/reconstruction/mutual_information_matrix.py
def mutual_info_node_pair(JointP_jl, ProduP_jl):
    """
    Calculate the mutual information between two nodes.

    Params
    ------
    JointP_jl (np.ndarray): nbins x nbins array of two nodes' joint probability distributions
    ProduP_jl (np.ndarray): nbins x nbins array of two nodes' product probability distributions

    Returns
    -------
    I_jl (float): the mutual information between j and l, or
                  the (j,l)'th entry of the mutual information matrix
                  Note: np.log returns an information value in nats
    """

    I_jl = 0 # initialize the mutual information to zero

    for q,p in zip(JointP_jl.flatten(), ProduP_jl.flatten()):
        if q > 0 and p > 0: # avoid log(0) or dividing by zero
            I_jl += q * np.log( q / p ) # an instance of the KL divergence

    return I_jl

    Calculate the mutual information between two nodes.

    Params
    ------
    JointP_jl (np.ndarray): nbins x nbins array of two nodes' joint probability distributions
    ProduP_jl (np.ndarray): nbins x nbins array of two nodes' product probability distributions

    Returns
    -------
    I_jl (float): the mutual information between j and l, or
                  the (j,l)'th entry of the mutual information matrix
                  Note: np.log returns an information value in nats
    
Calculate the mutual information between two nodes.
Params

JointP_jl (np.ndarray): nbins x nbins array of two nodes' joint probability distributions
ProduP_jl (np.ndarray): nbins x nbins array of two nodes' product probability distributions

Returns

I_jl (float): the mutual information between j and l, or
the (j,l)'th entry of the mutual information matrix
Note: np.log returns an information value in nats
Calculate the mutual information between two nodes . Params JointP_jl ( np . ndarray ) : nbins x nbins array of two nodes ' joint probability distributions ProduP_jl ( np . ndarray ) : nbins x nbins array of two nodes ' product probability distributions Returns I_jl ( float ) : the mutual information between j and l or the ( j l ) ' th entry of the mutual information matrix Note : np . log returns an information value in nats
def mutual_info_node_pair(JointP_jl, ProduP_jl):
    I_jl = 0 
    for q,p in zip(JointP_jl.flatten(), ProduP_jl.flatten()):
        if q > 0 and p > 0: 
            I_jl += q * np.log( q / p ) 
    return I_jl
def mutual_info_node_pair ( JointP_jl , ProduP_jl ) : I_jl = 0 for q , p in zip ( JointP_jl . flatten ( ) , ProduP_jl . flatten ( ) ) : if q > 0 and p > 0 : I_jl += q * np . log ( q / p ) return I_jl
Calculate the mutual information between two nodes.
Calculate the mutual information between two nodes .
"""
    Calculate the mutual information between two nodes.

    Params
    ------
    JointP_jl (np.ndarray): nbins x nbins array of two nodes' joint probability distributions
    ProduP_jl (np.ndarray): nbins x nbins array of two nodes' product probability distributions

    Returns
    -------
    I_jl (float): the mutual information between j and l, or
                  the (j,l)'th entry of the mutual information matrix
                  Note: np.log returns an information value in nats
    """ # initialize the mutual information to zero # avoid log(0) or dividing by zero # an instance of the KL divergence
JointP_jl
ProduP_jl