sncosmo.nest_lc

sncosmo.nest_lc(data, model, vparam_names, bounds, guess_amplitude_bound=False, minsnr=5.0, priors=None, ppfs=None, npoints=100, method='single', maxiter=None, maxcall=None, modelcov=False, rstate=None, verbose=False, warn=True, **kwargs)[source]

Run nested sampling algorithm to estimate model parameters and evidence.

Parameters
dataTable or ndarray or dict

Table of photometric data. Must include certain columns. See the “Photometric Data” section of the documentation for required columns.

modelModel

The model to fit.

vparam_nameslist

Model parameters to vary in the fit.

boundsdict

Bounded range for each parameter. Bounds must be given for each parameter, with the exception of t0: by default, the minimum bound is such that the latest phase of the model lines up with the earliest data point and the maximum bound is such that the earliest phase of the model lines up with the latest data point.

guess_amplitude_boundbool, optional

If true, bounds for the model’s amplitude parameter are determined automatically based on the data and do not need to be included in bounds. The lower limit is set to zero and the upper limit is 10 times the amplitude “guess” (which is based on the highest-flux data point in any band). Default is False.

minsnrfloat, optional

Minimum signal-to-noise ratio of data points to use when guessing amplitude bound. Default is 5.

priorsdict, optional

Prior probability distribution function for each parameter. The keys should be parameter names and the values should be callables that accept a float. If a parameter is not in the dictionary, the prior defaults to a flat distribution between the bounds.

ppfsdict, optional

Prior percent point function (inverse of the cumulative distribution function) for each parameter. If a parameter is in this dictionary, the ppf takes precedence over a prior pdf specified in priors.

npointsint, optional

Number of active samples to use. Increasing this value increases the accuracy (due to denser sampling) and also the time to solution.

method{‘classic’, ‘single’, ‘multi’}, optional

Method used to select new points. Choices are ‘classic’, single-ellipsoidal (‘single’), multi-ellipsoidal (‘multi’). Default is ‘single’.

maxiterint, optional

Maximum number of iterations. Iteration may stop earlier if termination condition is reached. Default is no limit.

maxcallint, optional

Maximum number of likelihood evaluations. Iteration may stop earlier if termination condition is reached. Default is no limit.

modelcovbool, optional

Include model covariance when calculating chisq. Default is False.

rstateRandomState, optional

RandomState instance. If not given, the global random state of the numpy.random module will be used.

verbosebool, optional

Print running evidence sum on a single line.

warnbool, optional

Issue warning when dropping bands outside the model range. Default is True.

New in version 1.5.0

Returns
resResult

Attributes are:

  • niter: total number of iterations

  • ncall: total number of likelihood function calls

  • time: time in seconds spent in iteration loop.

  • logz: natural log of the Bayesian evidence Z.

  • logzerr: estimate of uncertainty in logz (due to finite sampling)

  • h: Bayesian information.

  • vparam_names: list of parameter names varied.

  • samples: 2-d ndarray, shape is (nsamples, nparameters). Each row is the parameter values for a single sample. For example, samples[0, :] is the parameter values for the first sample.

  • logprior: 1-d ndarray (length=nsamples); log(prior volume) for each sample.

  • logl: 1-d ndarray (length=nsamples); log(likelihood) for each sample.

  • weights: 1-d ndarray (length=nsamples); Weight corresponding to each sample. The weight is proportional to the prior * likelihood for the sample.

  • parameters: 1-d ndarray of weighted-mean parameter values from samples (including fixed parameters). Order corresponds to model.param_names.

  • covariance: 2-d ndarray of parameter covariance; indicies correspond to order of vparam_names. Calculated from samples and weights.

  • errors: OrderedDict of varied parameter uncertainties. Corresponds to square root of diagonal entries in covariance matrix.

  • ndof: Number of degrees of freedom (len(data) - len(vparam_names)).

  • bounds: Dictionary of bounds on varied parameters (including any automatically determined bounds).

  • data_mask: Boolean array the same length as data specifying whether each observation was used. New in version 1.5.0.

estimated_modelModel

A copy of the model with parameters set to the values in res.parameters.