Ejemplo n.º 1
0
    def calcweight(self, causevardata, affectedvardata, *_):
        """"Calculates the transfer entropy between two vectors containing
        timer series data.

        """
        # Calculate transfer entropy as the difference
        # between the forward and backwards entropy

        # Pass special estimator specific parameters in here

        transent_fwd, auxdata_fwd = transentropy.calc_infodynamics_te(
            self.infodynamicsloc,
            self.estimator,
            affectedvardata.T,
            causevardata.T,
            **self.parameters
        )

        transent_bwd, auxdata_bwd = transentropy.calc_infodynamics_te(
            self.infodynamicsloc,
            self.estimator,
            causevardata.T,
            affectedvardata.T,
            **self.parameters
        )

        transent_directional = transent_fwd - transent_bwd
        transent_absolute = transent_fwd

        return [transent_directional, transent_absolute], [auxdata_fwd, auxdata_bwd]
Ejemplo n.º 2
0
    def calcweight(self, causevardata, affectedvardata, weightcalcdata,
                   causevarindex, affectedvarindex):
        """"Calculates the transfer entropy between two vectors containing
        timer series data.

        """
        # Calculate transfer entropy as the difference
        # between the forward and backwards entropy

        # Pass special estimator specific parameters in here

        transent_fwd, auxdata_fwd = \
            transentropy.calc_infodynamics_te(
                self.infodynamicsloc, self.estimator,
                affectedvardata.T, causevardata.T, **self.parameters)

        transent_bwd, auxdata_bwd = \
            transentropy.calc_infodynamics_te(
                self.infodynamicsloc, self.estimator,
                causevardata.T, affectedvardata.T, **self.parameters)

        transent_directional = transent_fwd - transent_bwd
        transent_absolute = transent_fwd

        return [transent_directional, transent_absolute], \
            [auxdata_fwd, auxdata_bwd]
Ejemplo n.º 3
0
def tecalc_wrapper(causevardata, affectedvardata):

    te_fwd = calc_infodynamics_te(infodynamics_loc, estimator, causevardata.T,
                                  affectedvardata.T, **add_parameters)

    te_bwd = calc_infodynamics_te(infodynamics_loc, estimator,
                                  affectedvardata.T, causevardata.T,
                                  **add_parameters)

    return [te_fwd, te_bwd]
def tecalc_wrapper(causevardata, affectedvardata):

    te_fwd = calc_infodynamics_te(
        infodynamics_loc, estimator, causevardata.T, affectedvardata.T, **add_parameters
    )

    te_bwd = calc_infodynamics_te(
        infodynamics_loc, estimator, affectedvardata.T, causevardata.T, **add_parameters
    )

    return [te_fwd, te_bwd]
Ejemplo n.º 5
0
    def calc_surr_te(self, affected_data, causal_data, num):
        """Calculates surrogate transfer entropy values for significance
        threshold purposes.

        Two methods for generating surrogate data is available:
        iAAFT (Schreiber 2000a) or random_shuffle in time.

        Returns list of surrogate transfer entropy values of length num.

        """

        # The causal (or source) data is replaced by surrogate data,
        # while the affected (or destination) data remains unchanged.

        # Get the causal data in the correct format
        # for surrogate generation
        original_causal = np.zeros((1, len(causal_data)))
        original_causal[0, :] = causal_data

        if self.te_surr_method == 'iAAFT':
            surr_tsdata = \
                [data_processing.gen_iaaft_surrogates(
                    original_causal, 10)
                 for n in range(num)]

        elif self.te_surr_method == 'random_shuffle':
            surr_tsdata = \
                [data_processing.shuffle_data(causal_data) for n in range(num)]

        surr_te_fwd = []
        surr_te_bwd = []
        for n in range(num):

            surr_te_fwd.append(
                transentropy.calc_infodynamics_te(self.infodynamicsloc,
                                                  self.estimator,
                                                  affected_data,
                                                  surr_tsdata[n][0, :],
                                                  **self.parameters)[0])

            surr_te_bwd.append(
                transentropy.calc_infodynamics_te(self.infodynamicsloc,
                                                  self.estimator,
                                                  surr_tsdata[n][0, :],
                                                  affected_data,
                                                  **self.parameters)[0])

        surr_te_directional = \
            [surr_te_fwd[n] - surr_te_bwd[n] for n in range(num)]

        surr_te_absolute = [surr_te_fwd[n] for n in range(num)]

        return surr_te_directional, surr_te_absolute