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

ENH: Use exponentials in place of inversion in Rayleigh and geometric #18666

Merged
merged 1 commit into from Mar 23, 2021

Conversation

bashtage
Copy link
Contributor

Use exponentials rather than generating exponentials via inversion

Use exponentials rather than generating exponentials via inversion
@bashtage
Copy link
Contributor Author

These two generators are simple transformation of exponentials. Previously these were implemented using the inverse log(U). This PR replaces the inverse cdf with the faster Ziggurat implementation.

Some timings on Ubuntu showed an improvement of

  • About 200% for Rayleigh (6ms vs 18ms per million)
  • About 80% for geometric (26 to 16ms per million)

Windows has different gains. For some reason that is not totally obvious to me the log on windows is much faster than on Ubuntu. Probably less accurate, but just a guess, so the gains on Windows are less since the inverse method is faster. The gains are around 100% for Rayleigh and +25% for geometric.

@bashtage bashtage changed the title PERF: Use exponentials in place of inversion PERF: Use exponentials in place of inversion in Rayleigh and geometric Mar 22, 2021
@bashtage bashtage changed the title PERF: Use exponentials in place of inversion in Rayleigh and geometric ENH: Use exponentials in place of inversion in Rayleigh and geometric Mar 22, 2021
@charris charris merged commit c1ce397 into numpy:main Mar 23, 2021
@charris
Copy link
Member

charris commented Mar 23, 2021

Thanks Kevin.

@bashtage bashtage deleted the rayleigh-perf branch April 21, 2021 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants