netrd/reconstruction/mutual_information_matrix.py
def fit(self, TS, deg=15, nbins=10):
        """
        Reconstruct a network by calculating the mutual information between the
        probability distributions of the (binned) values of the time series of
        pairs of nodes, i and j.

        First, the mutual information is computed between each pair of vertices.
        Then, a thresholding condition is applied to obtain edges.

        Params
        ------
        TS (np.ndarray): Array consisting of $L$ observations from $N$ sensors.
        deg (int): mean degree of reconstructed graph
        nbins (int): number of bins for the pre-processing step (to yield a discrete probability distribution)

        Returns
        -------
        G (nx.Graph): A reconstructed graph with $N$ nodes.

        """

        N    = TS.shape[0]
        rang = [np.min(TS), np.max(TS)]

        # saving these lines because there is a chance the "binned_edges" data would be useful
#         _,bin_edges = np.histogram(TS[0], range=np.array(rang), bins=nbins)
#         self.results['bin_edges'] = bin_edges

        # mutual information requires a joint probability and a "product probability" distribution
        IndivP = find_individual_probability_distribution(TS, rang, nbins)
        ProduP = find_product_probability_distribution(IndivP, N)
        JointP = find_joint_probability_distribution(TS, rang, nbins)

        # calculate the mutual information between each pair of nodes--this is the
        # mutual information matrix
        I = mutual_info_all_pairs(JointP, ProduP, N)
        self.results['mutual_information_matrix'] = I

        # the adjacency matrix is the binarized thresholded mutual information matrix
        tau=threshold_from_degree(deg,I)
        A = np.array(I>tau, dtype=int)

        G = nx.from_numpy_matrix(A)
        self.results['G'] = G

        return G

        Reconstruct a network by calculating the mutual information between the
        probability distributions of the (binned) values of the time series of
        pairs of nodes, i and j.

        First, the mutual information is computed between each pair of vertices.
        Then, a thresholding condition is applied to obtain edges.

        Params
        ------
        TS (np.ndarray): Array consisting of $L$ observations from $N$ sensors.
        deg (int): mean degree of reconstructed graph
        nbins (int): number of bins for the pre-processing step (to yield a discrete probability distribution)

        Returns
        -------
        G (nx.Graph): A reconstructed graph with $N$ nodes.

        
Reconstruct a network by calculating the mutual information between the
probability distributions of the (binned) values of the time series of
pairs of nodes, i and j.

First, the mutual information is computed between each pair of vertices.
Then, a thresholding condition is applied to obtain edges.

Params

TS (np.ndarray): Array consisting of $L$ observations from $N$ sensors.
deg (int): mean degree of reconstructed graph
nbins (int): number of bins for the pre-processing step (to yield a discrete probability distribution)

Returns

G (nx.Graph): A reconstructed graph with $N$ nodes.
Reconstruct a network by calculating the mutual information between the probability distributions of the ( binned ) values of the time series of pairs of nodes i and j . First the mutual information is computed between each pair of vertices . Then a thresholding condition is applied to obtain edges . Params TS ( np . ndarray ) : Array consisting of $L$ observations from $N$ sensors . deg ( int ) : mean degree of reconstructed graph nbins ( int ) : number of bins for the pre - processing step ( to yield a discrete probability distribution ) Returns G ( nx . Graph ) : A reconstructed graph with $N$ nodes .
def fit(self, TS, deg=15, nbins=10):
        N    = TS.shape[0]
        rang = [np.min(TS), np.max(TS)]
        IndivP = find_individual_probability_distribution(TS, rang, nbins)
        ProduP = find_product_probability_distribution(IndivP, N)
        JointP = find_joint_probability_distribution(TS, rang, nbins)
        I = mutual_info_all_pairs(JointP, ProduP, N)
        self.results['mutual_information_matrix'] = I
        tau=threshold_from_degree(deg,I)
        A = np.array(I>tau, dtype=int)
        G = nx.from_numpy_matrix(A)
        self.results['G'] = G
        return G
def fit ( self , TS , deg = 15 , nbins = 10 ) : N = TS . shape [ 0 ] rang = [ np . min ( TS ) , np . max ( TS ) ] IndivP = find_individual_probability_distribution ( TS , rang , nbins ) ProduP = find_product_probability_distribution ( IndivP , N ) JointP = find_joint_probability_distribution ( TS , rang , nbins ) I = mutual_info_all_pairs ( JointP , ProduP , N ) self . results [ 'mutual_information_matrix' ] = I tau = threshold_from_degree ( deg , I ) A = np . array ( I > tau , dtype = int ) G = nx . from_numpy_matrix ( A ) self . results [ 'G' ] = G return G
Reconstruct a network by calculating the mutual information between the
probability distributions of the (binned) values of the time series of
pairs of nodes, i and j.
Reconstruct a network by calculating the mutual information between the probability distributions of the ( binned ) values of the time series of pairs of nodes i and j .
"""
        Reconstruct a network by calculating the mutual information between the
        probability distributions of the (binned) values of the time series of
        pairs of nodes, i and j.

        First, the mutual information is computed between each pair of vertices.
        Then, a thresholding condition is applied to obtain edges.

        Params
        ------
        TS (np.ndarray): Array consisting of $L$ observations from $N$ sensors.
        deg (int): mean degree of reconstructed graph
        nbins (int): number of bins for the pre-processing step (to yield a discrete probability distribution)

        Returns
        -------
        G (nx.Graph): A reconstructed graph with $N$ nodes.

        """ # saving these lines because there is a chance the "binned_edges" data would be useful #         _,bin_edges = np.histogram(TS[0], range=np.array(rang), bins=nbins) #         self.results['bin_edges'] = bin_edges # mutual information requires a joint probability and a "product probability" distribution # calculate the mutual information between each pair of nodes--this is the # mutual information matrix # the adjacency matrix is the binarized thresholded mutual information matrix
self
TS
deg
nbins