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

Vectorize joint distribution #3352

Merged
merged 3 commits into from
Jul 12, 2020
Merged

Conversation

cdcapano
Copy link
Contributor

@cdcapano cdcapano commented Jul 3, 2020

This further speeds up the joint distribution by allowing it work on an array of values. Since many (all?) of the distributions in the distributions module are not vectorized, you still can't do vectorized prior evaluation for most practical purposes, but this is a step in that direction.

My main reason for doing this was to speed up the rvs function when you have many constraints. Currently, this is quite slow, because it draws one point at a time, evaluating each as they go. In this patch, the rvs will draw a batch of points, then use the now vectorized contains function to evaluate them all at once. It will then keep the points that pass the constraints, and continue until it's acquired the requested size. On each loop it will also increase the size of the draws based on the previous loop's acceptance (up to a maximum of a million draws). In my test, the constraints resulted in only ~1 in 10000 draws being kept. With that, it would take potentially hours to draw 1000 points. With this patch, it takes ~minute.

@cdcapano cdcapano requested a review from ahnitz July 3, 2020 14:37
@cdcapano cdcapano force-pushed the vectorize_joint_dist branch from 81a6d41 to a8332a2 Compare July 3, 2020 15:53
@ahnitz
Copy link
Member

ahnitz commented Jul 10, 2020

@cdcapano Try rebasing from master

@cdcapano cdcapano force-pushed the vectorize_joint_dist branch from a8332a2 to 6348d2e Compare July 10, 2020 10:19
@ahnitz ahnitz merged commit f2d3d75 into gwastro:master Jul 12, 2020
lenona pushed a commit to lenona/pycbc that referenced this pull request Sep 14, 2020
* try to speed up rvs

* speed up rvs by doing batch draws

* fix typos
OliverEdy pushed a commit to OliverEdy/pycbc that referenced this pull request Apr 3, 2023
* try to speed up rvs

* speed up rvs by doing batch draws

* fix typos
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