Skip to content

polychron.mcmc Module

Module for performing MCMC algorithm needed to obtain calibrated age estimates for the parameters within a chronological model.

run_MCMC is the primary method which should be used to invoke the MCMC algorithm.

HPD_interval

HPD_interval(x_temp, lim=0.95, probs=[])

Get HPD interval for an array of phase/group lengths

theta_samp_func

theta_samp_func(GIBBS_THETAS, GIBBS_PHIS, KEY_REF, PHI_REF, RESULT_VEC, STRAT_VEC, CONTEXT_NO, TOPO_SORT, iter_num, GIBBS_DICT_1)

Gives a list of initial theta values for MCMC

phase_samp_func

phase_samp_func(key_reff, phi_reff, theta_vals, prev_phases, A, P, iter_num)

Gives a list of initial phase boundary values for mcmc

sampling_vec

sampling_vec(post_phase_vec, prev_phase_vec)

Gives vectors to sample between

phase_limits

phase_limits(phases, POST_PHASE)

Provides phase limits for a phase

accept_prob

accept_prob(accept_vec, phi_accept_vec, i)

Checks the acceptance rate for MCMC code

likeli

likeli(x_val, s_err, theta, CALIBRATION_DATA)

Calculates likelihood for a single value

likelihood_func

likelihood_func(x_val, s_err, a_val, p_val, CALIBRATION_DATA)

Likelihood over a range

strat_rel

strat_rel(site_dict, key, i_index, THETAS, CONTEXT_NO)

Gives nodes above and below a date

dict_seek_ordered_new

dict_seek_ordered_new(A, P, i_seek, key, site_dict, THETAS, CONTEXT_NO, RCD_ERR, RCD_EST, CALIBRATION)

Calc probability in a dictionary (new version)

dict_seek_ordered

dict_seek_ordered(A, P, i_seek, key, site_dict, THETAS, CONTEXT_NO, RCD_ERR, RCD_EST, CALIBRATION)

Calc probability in a dictionary

post_h

post_h(A, P, site_dict, THETAS, CONTEXT_NO, RCD_ERR, RCD_EST, CALIBRATION)

Calculates acceptance probability

dict_seek_4

dict_seek_4(i_dict, key, site_dict)

Finds probabilities for all paramters in sample

post_h_theta_phi_4

post_h_theta_phi_4(site_dict)

Calculates posterior prob for step 4

dict_update

dict_update(test_dict_2, post_t, post_p, inter, inter2, POST_PHASE, PHI_REF)

Updates the site dictionary

phase_bd_init_func

phase_bd_init_func(key_reff, phi_reff, theta_initt, prev_phases, A, P)

Gives a list of inital phase boundary values for MCMC

theta_init_func

theta_init_func(KEY_REF1, PHI_REF1, RESULT_VEC1)

Gives a list of inital theta values for MCMC

theta_init_func_n

theta_init_func_n(KEY_REF1, PHI_REF1, RESULT_VEC1, STRAT_VEC, P, CONTEXT_NO, TOPO_SORT)

Gives a list of inital theta values for MCMC

upp_samp_1

upp_samp_1(theta_samp, phis_samp, m, A, P, SAMP_VEC_TRACK, KEY_REF, PHI_REF, CONT_TYPE)

Upper sample 1 - oldest phase and next phase abutting or gap

upp_samp_2

upp_samp_2(theta_samp, phis_samp, m, A, P, SAMP_VEC_TRACK, KEY_REF, PHI_REF, CONT_TYPE)

Upper sample 2 - oldest phase and next phase is overlapping

upp_samp_3

upp_samp_3(theta_samp, phis_samp, m, A, P, SAMP_VEC_TRACK, KEY_REF, PHI_REF, CONT_TYPE)

Upper sample 3 - phase with prev phase abbuting and next phase abbuting or gap

upp_samp_4

upp_samp_4(theta_samp, phis_samp, m, A, P, SAMP_VEC_TRACK, KEY_REF, PHI_REF, CONT_TYPE)

Upper sample 4 - phase with prev phase abbuting and next phase overlap

upp_samp_5

upp_samp_5(theta_samp, phis_samp, m, A, P, SAMP_VEC_TRACK, KEY_REF, PHI_REF, CONT_TYPE)

Upper sample 5 - phase with prev phase overlap, next phase can be any relationship

upp_samp_6

upp_samp_6(theta_samp, phis_samp, m, A, P, SAMP_VEC_TRACK, KEY_REF, PHI_REF, CONT_TYPE)

Upper sample 6 - phase with prev phase gap next phase abbuting or gap

upp_samp_7

upp_samp_7(theta_samp, phis_samp, m, A, P, SAMP_VEC_TRACK, KEY_REF, PHI_REF, CONT_TYPE)

Upper sample 7 - phase with previous phase gap and next phase overlap

upp_samp_8

upp_samp_8(theta_samp, phis_samp, m, A, P, SAMP_VEC_TRACK, KEY_REF, PHI_REF, CONT_TYPE)

Upper sample 8 - phase with previous 2 overlapping, same as overlap samp_2, should delete

low_samp_1

low_samp_1(theta_samp, phis_samp, m, A, P, SAMP_VEC_TRACK, KEY_REF, PHI_REF, CONT_TYPE)

Lower sample 1 prev phase start, abbuting or gap and next phase abbuting

low_samp_2

low_samp_2(theta_samp, phis_samp, m, A, P, SAMP_VEC_TRACK, KEY_REF, PHI_REF, CONT_TYPE)

Lower sample 2 next phase abbuting and prev phase overlapping

low_samp_3

low_samp_3(theta_samp, phis_samp, m, A, P, SAMP_VEC_TRACK, KEY_REF, PHI_REF, CONT_TYPE)

Lower sample 3: next phase overlapping and prev phase can be any relationship

low_samp_4

low_samp_4(theta_samp, phis_samp, m, A, P, SAMP_VEC_TRACK, KEY_REF, PHI_REF, CONT_TYPE)

Lower sample 4 next phase gap and prev phase can be any relationship except overlap

low_samp_5

low_samp_5(theta_samp, phis_samp, m, A, P, SAMP_VEC_TRACK, KEY_REF, PHI_REF, CONT_TYPE)

Lower sample 5

low_samp_6

low_samp_6(theta_samp, phis_samp, m, A, P, SAMP_VEC_TRACK, KEY_REF, PHI_REF, CONT_TYPE)

Lower sample 6

low_samp_7

low_samp_7(theta_samp, phis_samp, m, A, P, SAMP_VEC_TRACK, KEY_REF, PHI_REF, CONT_TYPE)

Lower sample 7

overlap_samp_1

overlap_samp_1(theta_samp, phis_samp, m, A, P, SAMP_VEC_TRACK, KEY_REF, PHI_REF, CONT_TYPE)

Overlap sample 1 - if previous two samples are overlapping and next phase can be any relationship

overlap_samp_2

overlap_samp_2(theta_samp, phis_samp, m, A, P, SAMP_VEC_TRACK, KEY_REF, PHI_REF, CONT_TYPE)

Overlap sample 2

dict_form_func

dict_form_func(THETA_INITS, RESULT_VEC, CONTEXT_NO, STRAT_VEC, PHASE_BOUNDARY_INITS, POST_PHASE, PHI_REF, PREV_PHASE, KEY_REF, CONT_TYPE)

Initiating the inital dict

run_MCMC

run_MCMC(CALIBRATION, STRAT_VEC, RCD_EST, RCD_ERR, KEY_REF, CONTEXT_NO, PHI_REF, PREV_PHASE, POST_PHASE, TOPO_SORT, CONT_TYPE, PROGRESS_IO: Writable | None = None)

Run the MCMC algorithm for a set of input data from a Model, returning the tuple of results