Skip to content
Snippets Groups Projects
Commit 05bd9620 authored by Colm Talbot's avatar Colm Talbot
Browse files

update example on specifying the prior

parent b057cb1d
No related branches found
No related tags found
1 merge request!59Updating priors
......@@ -33,20 +33,13 @@ IFOs = [tupak.gw.detector.get_interferometer_with_fake_noise_and_injection(
sampling_frequency=sampling_frequency, outdir=outdir) for name in ['H1', 'L1', 'V1']]
# Set up prior
priors = dict()
# This loads in a predefined set of priors for BBHs.
priors = tupak.gw.prior.BBHPriorSet()
# These parameters will not be sampled
for key in ['tilt_1', 'tilt_2', 'phi_12', 'phi_jl', 'phase', 'iota', 'ra', 'dec', 'geocent_time', 'psi']:
priors[key] = injection_parameters[key]
# We can assign a default prior distribution, note this only works for certain parameters.
priors['mass_1'] = tupak.core.prior.create_default_prior(name='mass_1')
# We can make uniform distributions.
priors['mass_2'] = tupak.core.prior.Uniform(name='mass_2', minimum=20, maximum=40)
# We can load a prior distribution from a file, e.g., a uniform in comoving volume distribution.
# If no path is given it will look in it's directory of known distributions.
# Note: that this file is used for the default prior distribution for distance.
# Also note: this special case is coded in as tupak.prior.UniformComovingVolume.
priors['luminosity_distance'] = tupak.core.prior.FromFile('comoving.txt', name='luminosity_distance',
minimum=1e3, maximum=5e3)
# We can make a power-law distribution, p(x) ~ x^{alpha}
# Note: alpha=0 is a uniform distribution, alpha=-1 is uniform-in-log
priors['a_1'] = tupak.core.prior.PowerLaw(name='a_1', alpha=-1, minimum=1e-2, maximum=1)
......@@ -56,6 +49,7 @@ a_2 = np.linspace(0, 1, 1001)
p_a_2 = a_2 ** 4
priors['a_2'] = tupak.core.prior.Interped(name='a_2', xx=a_2, yy=p_a_2, minimum=0, maximum=0.5)
# Additionally, we have Gaussian, TruncatedGaussian, Sine and Cosine.
# It's also possible to load an interpolate a prior from a file.
# Finally, if you don't specify any necessary parameters it will be filled in from the default when the sampler starts.
# Enjoy.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment