Esempio n. 1
0
def test_fingerprint_correlation(fingerprints_data, observables):
    obs1, obs2 = observables
    T = fingerprints_data.transition_matrix
    ts = timescales(T, k=4 if fingerprints_data.sparse else None)
    R, D, L = rdl_decomposition(T, k=4 if fingerprints_data.sparse else None)
    mu = fingerprints_data.stationary_distribution
    tau = 7.5
    if not fingerprints_data.sparse:
        """k=None, tau=1"""
        acorr_amp = np.dot(mu * obs1, R) * np.dot(L, obs1)
        tsn, acorr_ampn = fingerprint_correlation(T, obs1)
        assert_allclose(tsn, ts)
        assert_allclose(acorr_ampn, acorr_amp)
        """k=None, tau=7.5"""
        tau = tau
        tsn, acorr_ampn = fingerprint_correlation(T, obs1, tau=tau)
        assert_allclose(tsn, tau * ts)
        assert_allclose(acorr_ampn, acorr_amp)
    """k=4, tau=1"""
    k = 4
    acorr_amp = np.dot(mu * obs1, R[:, 0:k]) * np.dot(L[0:k, :], obs1)
    tsn, acorr_ampn = fingerprint_correlation(T, obs1, k=k)
    assert_allclose(tsn, ts[0:k])
    assert_allclose(acorr_ampn, acorr_amp)
    """k=4, tau=7.5"""
    tau = tau
    tsn, acorr_ampn = fingerprint_correlation(T, obs1, k=k, tau=tau)
    assert_allclose(tsn, tau * ts[0:k])
    assert_allclose(acorr_ampn, acorr_amp)
    """Cross-correlation"""

    if not fingerprints_data.sparse:
        """k=None, tau=1"""
        corr_amp = np.dot(mu * obs1, R) * np.dot(L, obs2)
        tsn, corr_ampn = fingerprint_correlation(T, obs1, obs2=obs2)
        assert_allclose(tsn, ts)
        assert_allclose(corr_ampn, corr_amp)
        """k=None, tau=7.5"""
        tau = tau
        tsn, corr_ampn = fingerprint_correlation(T, obs1, obs2=obs2, tau=tau)
        assert_allclose(tsn, tau * ts)
        assert_allclose(corr_ampn, corr_amp)
    """k=4, tau=1"""
    corr_amp = np.dot(mu * obs1, R[:, 0:k]) * np.dot(L[0:k, :], obs2)
    tsn, corr_ampn = fingerprint_correlation(T, obs1, obs2=obs2, k=k)
    assert_allclose(tsn, ts[0:k])
    assert_allclose(corr_ampn, corr_amp)
    """k=4, tau=7.5"""
    tsn, corr_ampn = fingerprint_correlation(T, obs1, obs2=obs2, k=k, tau=tau)
    assert_allclose(tsn, tau * ts[0:k])
    assert_allclose(corr_ampn, corr_amp)
Esempio n. 2
0
 def test_fingerprint_correlation(self):
     """Autocorrelation"""
     """k=4, tau=1"""
     k = self.k
     acorr_amp = np.dot(self.mu * self.obs1, self.R) * np.dot(
         self.L, self.obs1)
     tsn, acorr_ampn = fingerprint_correlation(self.T, self.obs1, k=k)
     assert_allclose(tsn, self.ts)
     assert_allclose(acorr_ampn, acorr_amp)
     """k=4, tau=7.5"""
     tau = self.tau
     tsn, acorr_ampn = fingerprint_correlation(self.T,
                                               self.obs1,
                                               k=k,
                                               tau=tau)
     assert_allclose(tsn, tau * self.ts)
     assert_allclose(acorr_ampn, acorr_amp)
     """Cross-correlation"""
     """k=4, tau=1"""
     k = self.k
     corr_amp = np.dot(self.mu * self.obs1, self.R) * np.dot(
         self.L, self.obs2)
     tsn, corr_ampn = fingerprint_correlation(self.T,
                                              self.obs1,
                                              obs2=self.obs2,
                                              k=k)
     assert_allclose(tsn, self.ts)
     assert_allclose(corr_ampn, corr_amp)
     """k=4, tau=7.5"""
     tau = self.tau
     tsn, corr_ampn = fingerprint_correlation(self.T,
                                              self.obs1,
                                              obs2=self.obs2,
                                              k=k,
                                              tau=tau)
     assert_allclose(tsn, tau * self.ts)
     assert_allclose(corr_ampn, corr_amp)