Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimisation of Shannon Entropy function #27

Merged
merged 2 commits into from
Jun 9, 2023
Merged

Optimisation of Shannon Entropy function #27

merged 2 commits into from
Jun 9, 2023

Conversation

nikdon
Copy link
Owner

@nikdon nikdon commented Jun 9, 2023

  • Version for string inputs uses Counter to improve performance
  • Version for non-string
    • Uses np.unique with the return_counts=True parameter to directly obtain unique values and their corresponding counts from the time series array.
    • Utilizes NumPy's array operations to calculate frequencies and perform element-wise multiplication and summation without explicit loops.

Benchamrk:

Size Original Time Efficient Time (string) Efficient Time (non-string) Efficient (string) vs Original, % diff Efficient (non-string) vs Original, % diff
10 0.000839 0.000605 0.001009 27.89% -20.26%
100 0.033200 0.004940 0.001059 85.12% 96.81%
500 0.486557 0.022725 0.001692 95.33% 99.65%
1000 1.882986 0.046219 0.002610 97.55% 99.86%

@nikdon nikdon merged commit 6d2a541 into master Jun 9, 2023
@nikdon nikdon deleted the shannon branch June 10, 2023 15:33
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.

1 participant