Skip to content

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

Merged
charris merged 1 commit intonumpy:mainfrom
bashtage:rayleigh-perf
Mar 23, 2021
Merged

ENH: Use exponentials in place of inversion in Rayleigh and geometric#18666
charris merged 1 commit intonumpy:mainfrom
bashtage:rayleigh-perf

Conversation

@bashtage
Copy link
Copy Markdown
Contributor

Use exponentials rather than generating exponentials via inversion

Use exponentials rather than generating exponentials via inversion
@bashtage
Copy link
Copy Markdown
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
Copy Markdown
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.

2 participants