Skip to content

burstfit.mcmc

[view_source]

MCMC Objects

class MCMC()

[view_source]

Class to run MCMC on the burst model.

Arguments:

  • model_function - Function to create the model
  • sgram - 2D spectrogram data
  • initial_guess - Initial guess of parameters for MCMC (can be a dictionary or list)
  • param_names - Names of parameters
  • nwalkers - Number of walkers to use in MCMC
  • nsteps - Number of iterations to use in MCMC
  • skip - Number of samples to skip for burn-in
  • start_pos_dev - Percent deviation for start position of the samples
  • prior_range - Percent of initial guess to set as prior range
  • ncores - Number of CPUs to use
  • outname - Name of output files
  • save_results - Save MCMC samples to a file

ndim

 | @property
 | def ndim()

[view_source]

Returns the number of dimensions.

Returns:

number of dimensions

lnprior

 | def lnprior(params)

[view_source]

Prior function. Priors are uniform from (1-prior_range)initial_guess to (1+prior_range)initial_guess. Minimum prior for tau is set to 0.

Arguments:

  • params - Parameters to check.

Returns:

lnprob

 | def lnprob(params)

[view_source]

Log probability function.

Arguments:

  • params - Parameters to evaluate at.

Returns:

Prior + log likelihood at the inputs.

lnlk

 | def lnlk(inps)

[view_source]

Log likelihood function. Uses the model_function to generate the model.

Arguments:

  • inps - Parameters to evaluate at.

Returns:

Log likelihood.

set_initial_pos

 | def set_initial_pos()

[view_source]

Function to set the initial values of walkers and prior ranges. Minimum prior for tau is set to 0.

Returns:

set_priors

 | def set_priors()

[view_source]

Set priors for MCMC

Returns:

run_mcmc

 | def run_mcmc()

[view_source]

Runs the MCMC.

Returns:

Sampler object

get_chain

 | def get_chain(skip=None)

[view_source]

Returns the chanins from sampler object after removing some samples for burn-in.

Arguments:

  • skip - Number of steps to skip for burn-in.

Returns:

Sample chain.

 | def print_results()

[view_source]

Prints the results of MCMC analysis. It uses median values with 1-sigma errors based on MCMC posteriors.

Returns:

plot

 | def plot(save=False)

[view_source]

Plot the samples and corner plot of MCMC posteriors.

Arguments:

  • save - To save the corner plot.

Returns:

make_autocorr_plot

 | def make_autocorr_plot(save=False)

[view_source]

Make autocorrelation plot for MCMC (i.e autocorrelation time scale vs iteration) see https://emcee.readthedocs.io/en/stable/tutorials/autocorr/

Arguments:

  • save - To save the plot

Returns: