cogwheel.gw_prior.combined.MarginalizedDistanceIASPrior

class cogwheel.gw_prior.combined.MarginalizedDistanceIASPrior(**kwargs)

Bases: RegisteredPriorMixin, CombinedPrior

Prior for usage with MarginalizedDistanceLikelihood.

Similar to IASPrior except it does not include distance. Uniform in effective spin and detector-frame component masses.

Parameters:
**kwargs

The list of parameters to pass to a subclass cls of CombinedPrior can be found using cls.init_parameters().

Methods

from_reference_waveform_finder

Instantiate prior.Prior subclass with help from a likelihood.ReferenceWaveformFinder instance.

generate_random_samples

Sample the prior using rejection sampling.

get_fast_sampled_params

Return a list of parameter names that map to given "fast" standard parameters.

get_init_dict

Return keyword arguments to reproduce the class instance.

get_module_name

Name of the module that defines the instance's class.

init_parameters

Return parameters accepted by the class constructor.

inverse_transform

Transform standard parameter values to sampled parameter values.

inverse_transform_samples

Add columns in-place for self.sampled_params to samples.

ln_jacobian_determinant

Natural log Jacobian determinant of the inverse transform.

lnprior

Natural logarithm of the prior probability density.

lnprior_and_transform

Return log of the prior and standard parameters.

reinstantiate

Return a new instance of the class, possibly updating init_kwargs.

standard_lnprior

Log prior density in standard coordinates.

to_json

Write class instance to json file.

transform

Transform sampled parameter values to standard parameter values.

transform_samples

Add columns in-place for self.standard_params to samples.

unfold_apply

Return a function that unfolds its parameters and applies func to each unfolding.

Attributes

conditioned_on

folded_params

folded_reflected_params

folded_shifted_params

max_lnprior

Maximum log prior density, useful for rejection sampling.

periodic_params

prior_classes

range_dic

reflective_params

sampled_params

standard_params

subclass_registry

default_likelihood_class

alias of MarginalizedDistanceLikelihood

classmethod from_reference_waveform_finder(reference_waveform_finder, **kwargs)

Instantiate prior.Prior subclass with help from a likelihood.ReferenceWaveformFinder instance.

This will generate kwargs for:

  • tgps

  • par_dic_0

  • f_avg

  • f_ref

  • ref_det_name

  • detector_pair

  • t0_refdet

  • mchirp_range

Additional **kwargs can be passed to complete missing entries or override these.

generate_random_samples(n_samples, seed=None, return_lnz=False)

Sample the prior using rejection sampling.

This is more efficient for more uniform priors.

Parameters:
n_samplesint

How many samples to generate.

seed

Passed to numpy.default_rng, for reproducibility.

Returns:
samplespd.DataFrame

Columns are .sampled_params + .standard_params, and rows are samples distributed according to the prior.

lnz, dlnzfloat, float

Log of the integral of the prior over the bounds, and estimate of the 1-sigma uncertainty. Only returned if return_lnz is set to True. Useful for estimating the normalization constant of the prior. Note: This differs from the lnz that nested samplers (e.g. PyMultiNest or Nautilus) would compute, in that it has the phase-space volume differential applied. I.e. if lnprior == 0, lnz == log(prod(self.cubesize)) while nested samplers would return lnz == 0.

classmethod get_fast_sampled_params(fast_standard_params)

Return a list of parameter names that map to given “fast” standard parameters.

Useful for sampling fast-slow parameters. Updating fast sampling parameters is guaranteed to only change fast standard parameters.

get_init_dict(**kwargs)

Return keyword arguments to reproduce the class instance.

get_module_name()

Name of the module that defines the instance’s class.

classmethod init_parameters(include_optional=True)

Return parameters accepted by the class constructor.

The parameters are sorted by parameter kind (i.e. positional arguments first, keyword arguments last). The self parameter is excluded.

Parameters:
include_optionalbool

Whether to include parameters with defaults in the returned list.

Returns:
list of inspect.Parameter objects
inverse_transform(f_ref, m1, m2, s1z, s2z, iota, s1x_n, s1y_n, s2x_n, s2y_n, ra, dec, psi, t_geocenter, phi_ref, l1, l2)

Transform standard parameter values to sampled parameter values.

Take .standard_params + .conditioned_on parameters and return a dictionary with .sampled_params parameters.

inverse_transform_samples(samples: DataFrame)

Add columns in-place for self.sampled_params to samples.

Parameters:
samplespandas.Dataframe

Must include columns for .standard_params and .conditioned_on.

Raises:
ValueError

If samples.index is not a simple range.

ln_jacobian_determinant(f_ref, m1, m2, s1z, s2z, iota, s1x_n, s1y_n, s2x_n, s2y_n, ra, dec, psi, t_geocenter, phi_ref, l1, l2)

Natural log Jacobian determinant of the inverse transform.

Take .standard_params + .conditioned_on parameters and return a float representing

log|∂{sampled_params} / ∂{standard_params}|

(excluding any standard params that are fixed).

Parameters:
*par_vals, **par_dic

Standard and conditioned-on parameter values.

lnprior(mchirp, lnq, chieff, cumchidiff, costheta_jn, phi_jl_hat, phi12, cums1r_s1z, cums2r_s2z, costhetanet, phinet_hat, psi, t_refdet, phi_ref_hat)

Natural logarithm of the prior probability density.

Take .sampled_params + .conditioned_on parameters and return a float.

lnprior_and_transform(mchirp, lnq, chieff, cumchidiff, costheta_jn, phi_jl_hat, phi12, cums1r_s1z, cums2r_s2z, costhetanet, phinet_hat, psi, t_refdet, phi_ref_hat)

Return log of the prior and standard parameters.

Take sampled and conditioned-on parameters, and return a 2-element tuple with the log of the prior and a dictionary with standard parameters.

The reason for this function is that it is necessary to compute the transform in order to compute the prior, so if both are wanted it is efficient to compute them at once.

property max_lnprior

Maximum log prior density, useful for rejection sampling.

reinstantiate(**new_init_kwargs)

Return a new instance of the class, possibly updating init_kwargs.

Values not passed will be taken from the current instance.

standard_lnprior(**parameters)

Log prior density in standard coordinates.

Parameters:
**parameters

Values for .standard_params and .conditioned_on parameters.

to_json(dirname, basename=None, *, dir_permissions=493, file_permissions=420, overwrite=False)

Write class instance to json file.

It can then be loaded with read_json.

transform(mchirp, lnq, chieff, cumchidiff, costheta_jn, phi_jl_hat, phi12, cums1r_s1z, cums2r_s2z, costhetanet, phinet_hat, psi, t_refdet, phi_ref_hat)

Transform sampled parameter values to standard parameter values.

Take self.sampled_params + self.conditioned_on parameters and return a dictionary with self.standard_params parameters.

transform_samples(samples: DataFrame)

Add columns in-place for self.standard_params to samples.

Parameters:
samplespandas.Dataframe

Must include columns for .sampled_params and .conditioned_on.

Raises:
ValueError

If samples.index is not a simple range.

unfold_apply(func, otypes=(<class 'float'>, ))

Return a function that unfolds its parameters and applies func to each unfolding.

The returned function returns a list of length 2**n_folds.

Parameters:
funccallable

A python function or method.

otypesstr or list of dtypes

Output type, passed to np.vectorize. You can pass None to decide automatically, but then an extra function call will be made.

Returns:
callable

Unfolding function.