Hmc Checker Link -

# 4. Tree depth if hasattr(inference_data, "sample_stats") and hasattr(inference_data.sample_stats, "tree_depth"): depths = inference_data.sample_stats.tree_depth.values max_depth = np.max(depths) # depends on sampler # typical max depth is 10 at_max = (depths == max_depth).mean() if at_max > max_tree_depth_fraction: results["warnings"].append(f"Frequent max tree depth ({at_max:.2f})")

# 3. Divergent transitions if hasattr(inference_data, "sample_stats"): diverging = inference_data.sample_stats.diverging.values div_frac = np.mean(diverging) if div_frac > max_divergent_fraction: results["failures"].append(f"Divergent fraction = {div_frac:.3f} > {max_divergent_fraction}") results["passed"] = False elif div_frac > 0: results["warnings"].append(f"Some divergent transitions ({div_frac:.3f})") hmc checker

# For demo, create dummy data import pymc as pm with pm.Model(): x = pm.Normal("x") trace = pm.sample(1000, chains=2, return_inferencedata=True) # 4. Tree depth if hasattr(inference_data