本文整理汇总了Python中idtxl.data.Data.normalise方法的典型用法代码示例。如果您正苦于以下问题:Python Data.normalise方法的具体用法?Python Data.normalise怎么用?Python Data.normalise使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类idtxl.data.Data
的用法示例。
在下文中一共展示了Data.normalise方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_get_permuted_replications
# 需要导入模块: from idtxl.data import Data [as 别名]
# 或者: from idtxl.data.Data import normalise [as 别名]
def test_get_permuted_replications():
"""Test if permutation of replications works."""
# Load previously generated example data
path = os.path.join(os.path.dirname(__file__), 'data/')
res_0 = pickle.load(open(path + 'mute_results_0.p', 'rb'))
res_1 = pickle.load(open(path + 'mute_results_1.p', 'rb'))
comp_settings = {
'cmi_estimator': 'JidtKraskovCMI',
'n_perm_max_stat': 50,
'n_perm_min_stat': 50,
'n_perm_omnibus': 200,
'n_perm_max_seq': 50,
'tail': 'two',
'n_perm_comp': 6,
'alpha_comp': 0.2,
'stats_type': 'dependent'
}
comp = NetworkComparison()
comp._initialise(comp_settings)
comp._create_union(res_0, res_1)
# Check permutation for dependent samples test: Replace realisations by
# zeros and ones, check if realisations get swapped correctly.
dat1 = Data()
dat1.normalise = False
dat1.set_data(np.zeros((5, 100, 5)), 'psr')
dat2 = Data()
dat2.normalise = False
dat2.set_data(np.ones((5, 100, 5)), 'psr')
[cond_a_perm,
cv_a_perm,
cond_b_perm,
cv_b_perm] = comp._get_permuted_replications(data_a=dat1,
data_b=dat2,
target=1)
n_vars = cond_a_perm.shape[1]
assert (np.sum(cond_a_perm + cond_b_perm, axis=1) == n_vars).all(), (
'Dependent samples permutation did not work correctly.')
assert np.logical_xor(cond_a_perm, cond_b_perm).all(), (
'Dependent samples permutation did not work correctly.')
# Check permutations for independent samples test: Check the sum over
# realisations.
comp_settings['stats_type'] = 'independent'
comp = NetworkComparison()
comp._initialise(comp_settings)
comp._create_union(res_0, res_1)
[cond_a_perm,
cv_a_perm,
cond_b_perm,
cv_b_perm] = comp._get_permuted_replications(data_a=dat1,
data_b=dat2,
target=1)
n_samples = n_vars * dat1.n_realisations((0, comp.union['max_lag']))
assert np.sum(cond_a_perm + cond_b_perm, axis=None) == n_samples, (
'Independent samples permutation did not work correctly.')
# test unequal number of replications
dat2.generate_mute_data(100, 7)
with pytest.raises(AssertionError):
comp._get_permuted_replications(data_a=dat1, data_b=dat2, target=1)