pint.bayesian.BayesianTiming

class pint.bayesian.BayesianTiming(model, toas, use_pulse_numbers=False, prior_info=None)[source]

Bases: object

A wrapper around the PINT API that provides lnprior, prior_transform, lnlikelihood, and lnposterior functions. This interface can be used to draw posterior samples using the sampler of your choice.

Parameters:
  • model (pint.models.timing_model.TimingModel) – Contains the input timing model. The best-fit values stored in this object are not used.

  • toas (pint.toa.TOAs) – Contains the input toas.

  • use_pulse_numbers (bool, optional) – How to handle phase wrapping. If True, will use the pulse numbers from the toas object while creating pint.residuals.Residuals objects. Otherwise will use the nearest integer.

  • prior_info (dict, optional) – A dict containing the prior information on free parameters. This parameter supersedes any priors present in the model.

Notes

  1. The prior attribute of each free parameter in the model object should be set to an instance of pint.models.priors.Prior.

  2. The parameters of BayesianTiming.model will change for every likelihood function call. These parameters in general will not be the best-fit values. Hence, it is NOT a good idea to save it as a par file.

  3. Both narrow-band and wide-band TOAs are supported.

  4. Currently, only uniform and normal distributions are supported in prior_info. More general priors should be set directly in the TimingModel object before creating the BayesianTiming object. Here is an example prior_info object:

    ```
    prior_info = {
        "F0" : {
            "distr" : "normal",
            "mu" : 1,
            "sigma" : 0.00001
        },
        "EFAC1" : {
            "distr" : "uniform",
            "pmin" : 0.5,
            "pmax" : 2.0
        }
    }
    ```
    

See examples/bayesian-example-NGC6440E.py and examples/bayesian-wideband-example for detailed examples.

Methods

lnlikelihood(params)

The Log-likelihood function.

lnposterior(params)

Log-posterior function.

lnprior(params)

Basic implementation of a factorized log prior.

prior_transform(cube)

Basic implementation of prior transform for a factorized prior.

lnprior(params)[source]

Basic implementation of a factorized log prior. More complex priors must be separately implemented.

Args:

params (array-like): Parameters

Returns:

float: Value of the log-prior at params

prior_transform(cube)[source]

Basic implementation of prior transform for a factorized prior. More complex prior transforms must be separately implemented.

Args:

cube (array-like): Sample drawn from a uniform distribution defined in an nparams-dimensional unit hypercube.

Returns:

ndarray : Sample drawn from the prior distribution

lnlikelihood(params)[source]

The Log-likelihood function. If the model does not contain any noise components or if the model contains only uncorrelated noise components, this is equal to -chisq/2 plus the normalization term containing the noise parameters. If the the model contains correlated noise, this is equal to -chisq/2 plus the normalization term where chisq is the generalized least-squares metric. For reference, see, e.g., Lentati+ 2013.

Args:

params (array-like): Parameters

Returns:

float: The value of the log-likelihood at params

lnposterior(params)[source]

Log-posterior function. If the prior evaluates to zero, the likelihood is not evaluated.

Args:

params (array-like): Parameters

Returns:

float: The value of the log-posterior at params