Sampling¶
Table of Contents
-
covid19_inference.sampling.
robust_sample
(model, tune, draws, final_chains, burnin_chains, burnin_draws=None, burnin_chains_2nd=None, burnin_draws_2nd=None, args_start_points=None, callback=None, sample_kwargs=None, **kwargs)[source]¶ Samples the model by starting more chains than needed (burn-in chains) and using only a reduced number final_chains for the final sampling. The final chains are randomly chosen (without replacement) weighted by their likelihood. :param model: The model :type model:
Cov19Model
:param tune: Number of tuning samples :type tune: int :param draws: Number of final samples :type draws: int :param final_chains: Number of draw chains :type final_chains: int :param burnin_chains: Number of chains used during burn-in, recommended to use about 2-3 time more thanthe number of final_chains
- Parameters
burnin_draws (int) – Length of the burn-in period, can be fairly short, on the order of a few hundreds draws. By default it set to tune//2
burnin_chains_2nd (int) – If not None, use a two-stage burn-in period, reducing the number of chains each time, Therefore, it should be less than burnin_chains and more than final_chains: burnin_chains > burnin_chains_2nd > final_chains
burnin_draws_2nd (int) – Length of the second burn-in period. By default it set burnin_draws
args_start_points (dict) – Arguments passed to get_start_points
tune_2nd (int) – If set, use different number of tuning samples for the second tuning
sample_kwargs – Arguments passed to pm.sample
**kwargs – Arguments passed to the nuts step function.
- Returns
trace (trace as multitrace object)
trace_az (trace as arviz object)
-
covid19_inference.sampling.
get_start_points
(trace, trace_az, frames_start=None, SD_chain_logl=2.5)[source]¶ Returns the starting points such that the chains deviate at most SD_chain_logl standard deviations from the chain with the highest likelihood. :param trace: :type trace: multitrace object :param trace_az: :type trace_az: arviz trace object :param frames_start: Which frames to use for calculating the mean likelihood and its standard deviation.
By default it is set to the last third of the tuning samples