From 05bd9620f2d99970080e3d24d44938c065dcc1c0 Mon Sep 17 00:00:00 2001 From: Colm Talbot <colm.talbot@ligo.org> Date: Mon, 11 Jun 2018 14:55:24 +1000 Subject: [PATCH] update example on specifying the prior --- .../injection_examples/how_to_specify_the_prior.py | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/examples/injection_examples/how_to_specify_the_prior.py b/examples/injection_examples/how_to_specify_the_prior.py index e6d3aa8c1..67e3e209b 100644 --- a/examples/injection_examples/how_to_specify_the_prior.py +++ b/examples/injection_examples/how_to_specify_the_prior.py @@ -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. -- GitLab