Skip to content
Snippets Groups Projects

make sure constraints aren't sampled

Merged Colm Talbot requested to merge fix-prior-sampling into master

@gregory.ashton @charlie.hoy @sylvia.biscoveanu I had a stab at fixing the sampling issue (#434 (closed)). I've been aware of this for a while and kind of neglecting it...

I'm pretty sure the issue was because when sampling from the whole prior, the list of parameters includes constraints and if the first one is a constraint everything gets messed up.

I set it to manually remove any constraints and it works in basically zero time.

In [5]: prior = bilby.gw.prior.BNSPriorDict()                                                                                                                                                       
18:23 bilby INFO    : No prior given, using default BNS priors in /Users/ctal0001/modules/bilby/bilby/gw/prior_files/binary_neutron_stars.prior.
r
In [6]: prior['chirp_mass'] = bilby.core.prior.Uniform(1.3, 1.4)                                                                                                                                    

In [7]: prior['mass_ratio'] = bilby.core.prior.Uniform(0.5, 1)                                                                                                                                      

In [8]: prior['mass_1'] = bilby.core.prior.Constraint(1, 2)                                                                                                                                         

In [9]: prior['mass_2'] = bilby.core.prior.Constraint(1, 2)                                                                                                                                         

In [10]: %timeit prior.sample(1000)                                                                                                                                                                 
2.63 ms ± 67.1 µs per loop (mean ± std. dev. of 7 runs, 100 loops each)

I'm happy to go with !660 (diffs) if people prefer, personally I prefer this one as it's somewhat vectorised.

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
Please register or sign in to reply
Loading