Sampling¶
Table of Contents
-
covid19_inference.sampling.
robust_sample
(model, tune, draws, tuning_chains, final_chains, return_tuning=False, args_start_points=None, tune_2nd=None, **kwargs)[source]¶ Samples the model by starting more chains than needed (tuning 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 tuning_chains: Number of tuning chains :type tuning_chains: int :param final_chains: Number of draw chains :type final_chains: int :param args_start_points: Arguments passed to get_start_points :type args_start_points: dict :param tune_2nd: If set, use different number of tuning samples for the second tuning :type tune_2nd: int :param **kwargs: Arguments passed to pm.sample- 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
- Parameters
SD_chain_logl (float) – The number of standard deviations. 2.5 as default
- Returns
start_points – A list of starting points
logl_mean – The mean log-likelihood of the starting points