计算说明(本节列出脚本中用于计算与检验的公式与步骤,便于复现):

1) 概率估计
   - 观测计数 A_i 为某类别的观测次数,总试验次数为 N(或在两类比较中为 m = A + B)。
   - 类别的估计概率: p_hat = A / N (若只比较两类,则条件概率 p_hat = A / m)。

2) Wilson 置信区间(用于单个类别概率的置信区间,双侧)
   - 给定显著性水平 alpha(双侧),先计算 z = Phi^{-1}(1 - alpha/2)。
   - 设 p_hat = A / N,
     denom = 1 + z^2 / N
     center = p_hat + z^2 / (2N)
     rad = z * sqrt( p_hat*(1-p_hat)/N + z^2/(4N^2) )
     下界 lower = (center - rad) / denom
     上界 upper = (center + rad) / denom
   - 区间被截断到 [0,1]。

3) 两类显著性比较(用于判断 A > B)
   - 只看落在 A 或 B 的样本,令 m = A + B。
   - 在原假设 H0: p_A = p_B(条件下 p = 0.5)下,A ~ Binomial(m, 0.5)。
   - 使用精确二项检验(binomtest)做单侧检验:H1: p_A > 0.5(即 A 的条件概率大于 B)。
   - 得到单侧 p_value(脚本中称为原始 p_value)。

4) 多重比较校正(组内 Bonferroni)
   - 在同一组(例如门组或某方向子组)内做所有两两比较,若组内共有 T 个两两比较,
     则每次检验的显著性阈值设为 alpha_per_test = overall_alpha / T(overall_alpha 默认为 0.05)。
   - 仅当单侧 p_value <= alpha_per_test 时,记录显著结论 A>B(或 B>A)。

5) 差值与效应量(使用总样本 N 作为分母)
   - 在两类比较中,差值定义为:
       diff_total = (A/N) - (B/N),其中 N 为总样本量。
   - 这样差值直接反映在总样本中的概率差异,便于与“误差 ≤1%(按 N 分母)”规则对齐。
   - 在结论页中,差值单元格按以下规则着色:
       <1% → 灰色;1%~2% → 黄色;≥2% → 绿色。

6) 方向比较限制(脚本实现细节)
   - 方向分为两组:直角组 = {Left, Up, Right, Down};斜角组 = {Up-Left, Up-Right, Down-Right, Down-Left}。
   - 仅在组内做两两比较,不跨组比较。

7) 概率统计表(概率统计页)
   - 每个类别的概率由原始计数除以 Total 得到:Door_X = Door_X_count / Total;Dir_Y = Dir_Y_count / Total。

8) 均值/方差/标准差(均值偏差页)
   - 组内均值(例如门组): mean = mean(p_i)(忽略为 0 的项以避免 Total=0 的影响)。
   - 以百分比形式计算偏差列: (p_i - mean) * 100。
   - 方差(%^2)使用样本方差(ddof=0),标准差为方差的平方根(%)。

本页(结论-方向)说明:
 - 方向被分为两组:直角组(4 个)与斜角组(4 个),每组内分别做两两比较。
 - 每组内比较数量均为 T = C(4,2) = 6,组内 Bonferroni 校正 alpha_per_test = 0.05 / 6。
 - 仅在组内记录显著结论,格式同上: 实验编号 | 结论 | p_value | A_count | B_count | 差值(pA-pB, N分母)。
实验编号 结论 p_value A_count B_count 差值(pA-pB, N分母)
1c Left>Down 0.005904151 4215 3986 0.00666
1c Up-Left>Down-Right 0.002343282 4626 4357 0.007824
1c Up-Left>Down-Left 0.000108048 4626 4276 0.01018
1c Up-Right>Down-Right 0.001742652 4635 4357 0.008086
1c Up-Right>Down-Left 7.44417E-05 4635 4276 0.010442
1d Up-Left>Down-Right 0.003420348 4609 4352 0.007475
1d Up-Left>Down-Left 0.002304287 4609 4340 0.007824
1d Up-Right>Down-Right 0.004800635 4598 4352 0.007155
1d Up-Right>Down-Left 0.003278344 4598 4340 0.007504
2c Left>Up 0.000243446 4397 4075 0.009366
2c Left>Down 3.12867E-09 4397 3868 0.015386
2c Right>Down 3.95455E-06 4272 3868 0.011751
2c Up-Right>Down-Left 0.000369957 4601 4282 0.009278
2d Left>Down 0.004006657 4287 4044 0.007068
3c Left>Right 0.001414153 4012 3748 0.007679
3c Left>Down 1.77116E-36 4012 2964 0.030482
3c Up>Right 3.92579E-06 4146 3748 0.011576
3c Up>Down 4.53742E-45 4146 2964 0.034379
3c Right>Down 5.44519E-22 3748 2964 0.022803
3c Up-Left>Down-Right 1.9703E-28 5477 4385 0.031762
3c Up-Left>Down-Left 7.67734E-34 5477 4285 0.03467
3c Up-Right>Down-Right 1.8211E-23 5364 4385 0.028475
3c Up-Right>Down-Left 2.239E-28 5364 4285 0.031384
3d Left>Down 2.12866E-09 3772 3278 0.014368
3d Up>Right 0.002562641 3891 3647 0.007097
3d Up>Down 2.37295E-13 3891 3278 0.01783
3d Right>Down 4.86284E-06 3647 3278 0.010733
3d Up-Left>Down-Right 2.29416E-10 5278 4656 0.018091
3d Up-Left>Down-Left 6.94871E-10 5278 4673 0.017597
3d Up-Right>Down-Right 4.81601E-08 5186 4656 0.015415
3d Up-Right>Down-Left 1.25069E-07 5186 4673 0.014921
4c Left>Down 1.5367E-32 4007 3017 0.028795
4c Up>Down 1.94731E-27 3915 3017 0.026119
4c Right>Down 6.19616E-23 3827 3017 0.02356
4c Up-Left>Down-Right 3.9257E-21 5396 4466 0.02705
4c Up-Left>Down-Left 1.35319E-22 5396 4433 0.02801
4c Up-Right>Down-Right 3.11725E-18 5320 4466 0.024839
4c Up-Right>Down-Left 1.38366E-19 5320 4433 0.025799
4d Left>Down 3.6826E-08 3869 3409 0.013379
4d Up>Down 5.73162E-05 3736 3409 0.009511
4d Right>Down 0.000345129 3696 3409 0.008348
4d Up-Left>Down-Right 2.75066E-05 5170 4767 0.011722
4d Up-Left>Down-Left 3.54165E-07 5170 4677 0.014339
4d Up-Right>Down-Right 0.001772989 5057 4767 0.008435
4d Up-Right>Down-Left 6.10457E-05 5057 4677 0.011053
5b Up-Left>Down-Left 0.006720235 5199 4949 0.007271
6 Up>Left 4.1132E-06 3687 3313 0.010878
6 Down>Left 0.004060213 3533 3313 0.006399
6 Up>Right 5.36465E-07 3687 3279 0.011867
6 Down>Right 0.001085852 3533 3279 0.007388
6 Down-Left>Up-Left 3.0059E-06 5420 4958 0.013438
6 Down-Left>Up-Right 1.62496E-05 5420 4995 0.012361
6a Up>Left 4.1132E-06 3687 3313 0.010878
6a Down>Left 0.004060213 3533 3313 0.006399
6a Up>Right 5.36465E-07 3687 3279 0.011867
6a Down>Right 0.001085852 3533 3279 0.007388
6a Down-Left>Up-Left 3.0059E-06 5420 4958 0.013438
6a Down-Left>Up-Right 1.62496E-05 5420 4995 0.012361
6b Up>Left 4.1132E-06 3687 3313 0.010878
6b Down>Left 0.004060213 3533 3313 0.006399
6b Up>Right 5.36465E-07 3687 3279 0.011867
6b Down>Right 0.001085852 3533 3279 0.007388
6b Down-Left>Up-Left 3.0059E-06 5420 4958 0.013438
6b Down-Left>Up-Right 1.62496E-05 5420 4995 0.012361
7 Up>Down 8.13118E-05 3648 3332 0.009191
7 Up-Left>Down-Right 0.001894498 5304 5009 0.00858
7 Up-Left>Down-Left 2.6668E-05 5304 4895 0.011896
7 Up-Right>Down-Left 0.000263997 5245 4895 0.01018
7b Up-Left>Down-Left 7.91448E-05 5278 4896 0.011111
7b Up-Right>Down-Left 0.001162735 5203 4896 0.008929
8c Down-Left>Up-Right 0.00152878 5246 4946 0.008726
10 Up>Left 0.000101032 4036 3708 0.00954
10 Left>Down 5.48302E-21 3708 2947 0.022134
10 Up>Right 5.16812E-07 4036 3608 0.012449
10 Up>Down 3.33452E-39 4036 2947 0.031674
10 Right>Down 1.69347E-16 3608 2947 0.019226
10 Up-Left>Down-Right 6.01128E-35 5638 4408 0.035776
10 Up-Left>Down-Left 6.80331E-39 5638 4341 0.037724
10 Up-Right>Down-Right 7.06434E-38 5695 4408 0.037433
10 Up-Right>Down-Left 5.4779E-42 5695 4341 0.039382
11 Up>Left 1.1324E-06 3635 3242 0.011431
11 Down>Left 3.50439E-06 3615 3242 0.010849
11 Up>Right 0.007865582 3635 3431 0.005934
11 Down-Right>Up-Left 7.4757E-09 5447 4871 0.016753
11 Down-Left>Up-Left 3.02149E-05 5276 4871 0.01178
11 Down-Right>Up-Right 4.9325E-09 5447 4864 0.016957
11 Down-Left>Up-Right 2.23197E-05 5276 4864 0.011983
11a Up>Left 1.83905E-06 3728 3338 0.011343
11a Down>Left 0.003759283 3561 3338 0.006486
11a Up>Right 1.12634E-05 3728 3370 0.010413
11a Down-Right>Up-Left 0.000115614 5235 4864 0.010791
11a Down-Left>Up-Left 2.82882E-07 5371 4864 0.014747
11a Down-Right>Up-Right 0.000744907 5235 4914 0.009337
11a Down-Left>Up-Right 3.4447E-06 5371 4914 0.013292
12 Left>Right 1.88796E-08 3273 2842 0.012536
12 Left>Down 4.01329E-12 3273 2742 0.015445
12 Up>Right 3.07292E-08 3266 2842 0.012332
12 Up>Down 7.31204E-12 3266 2742 0.015241
12 Up-Left>Up-Right 3.22788E-06 6049 5562 0.014165
12 Up-Left>Down-Right 2.05694E-21 6049 5055 0.028911
12 Up-Left>Down-Left 1.18466E-05 6049 5592 0.013292
12 Up-Right>Down-Right 4.51538E-07 5562 5055 0.014747
12 Down-Left>Down-Right 1.02005E-07 5592 5055 0.015619