Skip to content

In built method to sample params with a constraint? #1547

Discussion options

You must be logged in to vote

You can probably achieve that with the RestrictedPrior.

from sbi.utils import RestrictedPrior

prior = BoxUniform(-torch.ones((3,)), torch.ones((3,)))
def accept_reject_fn(params):
   return True is torch.sum(params) > 1.5 else False
restricted_prior = RestrictedPrior(prior, accept_reject_fn)

Let me know if this works!
Michael

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@jorobledo
Comment options

Answer selected by janfb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested
3 participants
Converted from issue

This discussion was converted from issue #1545 on March 31, 2025 07:15.