# 绘制三张对比图
fig, axes = plt.subplots(1, 3, figsize=(18, 5)) # 创建1行3列子图
# 左图:模拟的"真实"抽样分布
axes[0].hist(simulated_alpha_values, bins=40, alpha=0.7, color='#3498DB', edgecolor='black') # 绘制直方图
axes[0].axvline(np.mean(simulated_alpha_values), color='red', linestyle='--', label=f'均值: {np.mean(simulated_alpha_values):.3f}') # 标记均值
axes[0].set_xlabel('α', fontsize=12) # X轴标签
axes[0].set_title('模拟抽样分布\n(上帝视角基准)', fontsize=13) # 标题
axes[0].legend() # 图例
axes[0].grid(True, alpha=0.3) # 网格
# 中图:Bootstrap分布
axes[1].hist(bootstrap_alpha_values, bins=40, alpha=0.7, color='#E74C3C', edgecolor='black') # 绘制直方图
axes[1].axvline(original_alpha_estimate, color='blue', linewidth=2, label=f'原始估计: {original_alpha_estimate:.3f}') # 标记原始估计
axes[1].set_xlabel('α', fontsize=12) # X轴标签
axes[1].set_title(f'Bootstrap分布\n(SE = {bootstrap_se:.3f})', fontsize=13) # 标题
axes[1].legend() # 图例
axes[1].grid(True, alpha=0.3) # 网格
# 右图:箱线图对比
axes[2].boxplot([simulated_alpha_values, bootstrap_alpha_values], labels=['模拟分布', 'Bootstrap'], patch_artist=True, boxprops=dict(facecolor='lightblue')) # 箱线图
axes[2].set_title('分布对比', fontsize=13) # 标题
axes[2].grid(True, alpha=0.3, axis='y') # Y轴网格
plt.tight_layout() # 调整布局
plt.show() # 显示图表