Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bilby
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
lscsoft
bilby
Commits
971deb31
Commit
971deb31
authored
5 years ago
by
Moritz Huebner
Browse files
Options
Downloads
Plain Diff
Merge branch 'constraint-documentation' into 'master'
update conversion documentation See merge request
!416
parents
ab208870
64ba3222
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!416
update conversion documentation
Pipeline
#56987
passed
5 years ago
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
docs/conversion.txt
+6
-0
6 additions, 0 deletions
docs/conversion.txt
docs/prior.txt
+75
-1
75 additions, 1 deletion
docs/prior.txt
with
81 additions
and
1 deletion
docs/conversion.txt
+
6
−
0
View file @
971deb31
...
...
@@ -7,5 +7,11 @@ E.g., sampling in chirp mass and mass ratio can be much more efficient than samp
We have many functions to do this.
These are used in multiple places:
- `PriorDict`s have a `conversion_function`, for the GW PriorDicts, these are from this module.
- `WaveformGenerator`s can use a `parameter_conversion`, again these are from this module.
- A `conversion_function` can be passed to `run_sampler`, this is done as a post-processing step.
For CBCs either `generate_all_bbh_parameters` or `generate_all_bns_parameters` can be used.
.. automodule:: bilby.gw.conversion
:members:
\ No newline at end of file
This diff is collapsed.
Click to expand it.
docs/prior.txt
+
75
−
1
View file @
971deb31
...
...
@@ -83,11 +83,85 @@ note that this list is incomplete.
:members:
:special-members:
-----------------------
Defining your own prior
=======================
-----------------------
You can define your own by subclassing the :code:`bilby.prior.Prior` class.
.. autoclass:: bilby.core.prior.Prior
:members:
:special-members:
-----------------
Prior Constraints
-----------------
Added v. 0.4.3
This allows cuts to be specified in the prior space.
You can provide the `PriorDict` a `conversion_function` and a set of `Constraint` priors to remove parts of the prior space.
*Note*: after doing this the prior probability will not be normalised.
Simple example
==============
Sample from uniform distributions in two parameters x and y with the condition x >= y.
First thing: define a function which generates z=x-y from x and y.
.. code:: python
def convert_x_y_to_z(parameters):
"""
Function to convert between sampled parameters and constraint parameter.
Parameters
----------
parameters: dict
Dictionary containing sampled parameter values, 'x', 'y'.
Returns
-------
dict: Dictionary with constraint parameter 'z' added.
"""
parameters['z'] = parameters['x'] - parameters['y']
return parameters
Create our prior:
.. code:: python
from bilby.core.prior import PriorDict, Uniform, Constraint
priors = PriorDict(conversion_function=convert_x_y_to_z)
priors['x'] = Uniform(minimum=0, maximum=10)
priors['y'] = Uniform(minimum=0, maximum=10)
priors['z'] = Constraint(minimum=0, maximum=10)
Sample from this distribution and plot the samples.
.. code:: python
import matplotlib.pyplot as plt
samples = priors.sample(1000000)
plt.hist2d(samples['x'], samples['y'], bins=100, cmap='Blues')
plt.xlabel('$x$')
plt.ylabel('$y$')
plt.tight_layout()
plt.show()
plt.close()
------
Gravitational wave priors
=========================
We provide default conversion functions for the BBH and BNS PriorDicts.
For BBHs this generates all the BBH mass parameters so constraints can be placed on any mass parameters.
For BNSs it also generates the tidal deformability parameters.
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment