pint.simulation.calculate_random_models
- pint.simulation.calculate_random_models(fitter: Fitter, toas: TOAs, Nmodels: int = 100, keep_models: bool = True, return_time: bool = False, params: str = 'all') Tuple[ndarray, list | None] [source]
Calculates random models based on the covariance matrix of the fitter object.
returns the new phase differences compared to the original model optionally returns all of the random models
- Parameters:
fitter (pint.fitter.Fitter) – current fitter object containing a model and parameter covariance matrix
toas (pint.toa.TOAs) – TOAs to calculate models
Nmodels (int, optional) – number of random models to calculate
keep_models (bool, optional) – whether to keep and return the individual random models (slower)
params (list, optional) – if specified, selects only those parameters to vary. Default (‘all’) is to use all parameters other than Offset
- Returns:
dphase (np.ndarray) – phase difference with respect to input model, size is [Nmodels, len(toas)]
random_models (list, optional) – list of random models (each is a
pint.models.timing_model.TimingModel
)
Example
>>> from pint.models import get_model_and_toas >>> from pint import fitter, toa >>> import pint.simulation >>> import io >>> >>> # the locations of these may vary >>> timfile = "tests/datafile/NGC6440E.tim" >>> parfile = "tests/datafile/NGC6440E.par" >>> m, t = get_model_and_toas(parfile, timfile) >>> # fit the model to the data >>> f = fitter.WLSFitter(toas=t, model=m) >>> f.fit_toas() >>> >>> # make fake TOAs starting at the end of the >>> # current data and going out 100 days >>> tnew = simulation.make_fake_toas_uniform(t.get_mjds().max().value, >>> t.get_mjds().max().value+100, 50, model=f.model) >>> # now make random models >>> dphase, mrand = pint.simulation.calculate_random_models(f, tnew, Nmodels=100)