Skip to content

Conversation

@MarkDana
Copy link
Collaborator

Just some speedup on matrix multiplication (e.g., multiplied by all ones matrix). 5-10 times faster (depends on sample size).

X = np.random.uniform(0, 1, (15000,))
Y = X ** 2 + np.random.uniform(0, 1, (15000,))
tic = time.time()
test_stat, p = hsic_test_gamma(X, Y)
print(f'now used: {time.time() - tic: .5f}s')

from causallearn.search.FCMBased.lingam.hsic import hsic_test_gamma as hsic_test_gamma_old
tic = time.time()
test_stat_old, p_old = hsic_test_gamma_old(X, Y)
print(f'originally used: {time.time() - tic: .5f}s')

assert np.isclose(test_stat, test_stat_old)
assert np.isclose(p, p_old)
print('equivalent test passed.')

'''
now used:  6.78904s
originally used:  65.28648s
equivalent test passed.
'''

@kunwuz kunwuz merged commit b3fab0c into py-why:main Apr 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants