MCMC Fitting¶

radvel.mcmc.
convergence_calculate
(chains, oldautocorrelation, minAfactor, maxArchange, minTz, maxGR)[source]¶ Calculate Convergence Criterion
Calculates the GelmanRubin statistic, autocorrelation time factor, relative change in autocorrellation time, and the number of independent draws for each parameter, as defined by Ford et al. (2006) (http://adsabs.harvard.edu/abs/2006ApJ…642..505F). The chain is considered wellmixed if all parameters have a GelmanRubin statistic of <= 1.03, the min autocorrelation time factor >= 75, a max relative change in autocorrelation time <= .01, and >= 1000 independent draws.
Parameters:  chains (array) – A 3 dimensional array of parameter values
 oldautocorrelation (float) – previously calculated autocorrelation time
 minAfactor (float) – minimum autocorrelation time factor to consider wellmixed
 maxArchange (float) – maximum relative change in autocorrelation time to consider wellmixed
 minTz (int) – minimum Tz to consider wellmixed
 maxGR (float) – maximum GelmanRubin statistic to consider wellmixed
Returns:  tuple containing:
 ismixed (bool):
Are the chains wellmixed?
 afactor (array):
A matrix containing the autocorrelation time factor for each parameter and ensemble combination
 archange (matrix):
A matrix containing the relative change in the autocorrelation time factor for each parameter and ensemble combination
 autocorrelation (matrix):
A matrix containing the autocorrelation time for each parameter and ensemble combination
 gelmanrubin (array):
An NPARS element array containing the GelmanRubin statistic for each parameter (equation 25)
 Tz (array):
An NPARS element array containing the number of independent draws for each parameter (equation 26)
Return type: tuple
 History:
 2010/03/01:
 Written: Jason Eastman  The Ohio State University
 2012/10/08:
 Ported to Python by BJ Fulton  University of Hawaii, Institute for Astronomy
 2016/04/20:
 Adapted for use in RadVel. Removed “angular” parameter.
 2019/10/24:
 Adapted to calculate and consider autocorrelation times

radvel.mcmc.
convergence_check
(minAfactor, maxArchange, maxGR, minTz, minsteps, minpercent, headless)[source]¶ Check for convergence
Check for convergence for a list of emcee samplers
Parameters:  minAfactor (float) – Minimum autocorrelation time factor for chains to be deemed wellmixed and halt the MCMC run
 maxArchange (float) – Maximum relative change in the autocorrelative time to be deemed wellmixed and halt the MCMC run
 maxGR (float) – Maximum GR statistic for chains to be deemed wellmixed and halt the MCMC run
 minTz (int) – Minimum Tz to consider wellmixed
 minsteps (int) – Minimum number of steps per walker before convergence tests are performed. Convergence checks will start after the minsteps threshold or the minpercent threshold has been hit.
 minpercent (float) – Minimum percentage of total steps before convergence tests are performed. Convergence checks will start after the minsteps threshold or the minpercent threshold has been hit.
 headless (bool) – if set to true, the convergence statistics will not be displayed in real time.

radvel.mcmc.
mcmc
(post, nwalkers=50, nrun=10000, ensembles=8, checkinterval=50, minAfactor=40, maxArchange=0.03, burnAfactor=25, burnGR=1.03, maxGR=1.01, minTz=1000, minsteps=1000, minpercent=5, thin=1, serial=False, save=False, savename=None, proceed=False, proceedname=None, headless=False)[source]¶ Run MCMC Run MCMC chains using the emcee EnsambleSampler :param post: radvel posterior object :type post: radvel.posterior :param nwalkers: (optional) number of MCMC walkers :type nwalkers: int :param nrun: (optional) number of steps to take :type nrun: int :param ensembles: (optional) number of ensembles to run. Will be run
in parallel on separate CPUsParameters:  checkinterval (int) – (optional) check MCMC convergence statistics every checkinterval steps
 minAfactor (float) – Minimum autocorrelation time factor to deem chains as wellmixed and halt the MCMC run
 maxArchange (float) – Maximum relative change in autocorrelation time to deem chains and wellmixed
 burnAfactor (float) – Minimum autocorrelation time factor to stop burnin period. Burnin ends once burnGr or burnAfactor are reached.
 burnGR (float) – (optional) Maximum GR statistic to stop burnin period. Burnin ends once burnGr or burnAfactor are reached.
 maxGR (float) – (optional) Maximum GR statistic for chains to be deemed wellmixed and halt the MCMC run
 minTz (int) – (optional) Minimum Tz to consider wellmixed
 minsteps (int) – Minimum number of steps per walker before convergence tests are performed. Convergence checks will start after the minsteps threshold or the minpercent threshold has been hit.
 minpercent (float) – Minimum percentage of total steps before convergence tests are performed. Convergence checks will start after the minsteps threshold or the minpercent threshold has been hit.
 thin (int) – (optional) save one sample every N steps (default=1, save every sample)
 serial (bool) – set to true if MCMC should be run in serial
 save (bool) – set to true to save MCMC chains that can be continued in a future run
 savename (string) – location of h5py file where MCMC chains will be saved for future use
 proceed (bool) – set to true to continue a previously saved run
 proceedname (string) – location of h5py file with previously MCMC run chains
 headless (bool) – if set to true, the convergence statistics will not display in real time
Returns: DataFrame containing the MCMC samples
Return type: DataFrame