Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
T = 100000
numpy.random.seed(None)
array = numpy.random.randn(3, T)
cov = numpy.array([[1., val_ana],[val_ana, 1.]])
array[:2, :] = numpy.random.multivariate_normal(
mean=numpy.zeros(2),
cov=cov, size=T).T
# Generate some confounding
if len(array) > 2:
array[0] += 0.5* array[2:].sum(axis=0)
array[1] += 0.7* array[2:].sum(axis=0)
# Transform to symbolic data
array = pp.quantile_bin_array(array.T, bins=16).T
dim, T = array.shape
xyz = numpy.array([0,1,2,2,2])
val_est = ci_cmi_symb.get_dependence_measure(array, xyz)
print(val_est)
print(_par_corr_to_cmi(val_ana))
numpy.testing.assert_allclose(numpy.array(_par_corr_to_cmi(val_ana)),
numpy.array(val_est),
atol=0.02)
def test_cmi_symb(cmi_symb, data_sample_d):
# Get the data sample values
small_array, _, corr_val, xyz, dim, T = data_sample_d
# Generate the full array
dim = 3
array = np.random.randn(dim, T)
array[:2, :] = small_array
# Generate some confounding
array[0] += 0.5* array[2:].sum(axis=0)
array[1] += 0.7* array[2:].sum(axis=0)
# Transform to symbolic data
array = pp.quantile_bin_array(array.T, bins=16).T
# Reset the dimension
xyz = np.array([0, 1, 2, 2, 2])
# Get the estimated value
val_est = cmi_symb.get_dependence_measure(array, xyz)
np.testing.assert_allclose(np.array(_par_corr_to_cmi(corr_val)),
np.array(val_est),
atol=0.02)