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

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分母)
1 Up>Left 0.002172017 3722 3479 0.008095
1a Up>Left 0.004435089 3710 3487 0.007429
1b Up>Left 0.003765959 3690 3463 0.007563
1b Down>Left 0.007600028 3669 3463 0.006863
1c Left>Down 0.008112929 3704 3499 0.00683
1c Up>Right 0.006021883 3740 3525 0.007163
1c Up>Down 0.002393533 3740 3499 0.008029
2c Left>Up 6.03884E-06 3861 3485 0.012527
2c Left>Down 1.83455E-09 3861 3359 0.016724
2c Right>Up 0.00084857 3753 3485 0.008929
2c Right>Down 1.57149E-06 3753 3359 0.013126
2c Up-Left>Down-Left 0.007401843 3963 3748 0.007163
2c Up-Right>Down-Right 0.000530009 4069 3778 0.009695
2c Up-Right>Down-Left 0.000147409 4069 3748 0.010694
2d Left>Down 2.31813E-05 3740 3395 0.011494
2d Right>Down 1.48957E-06 3792 3395 0.013226
2d Up-Right>Down-Right 0.000789492 4039 3759 0.009328
2d Up-Right>Down-Left 0.001356631 4039 3773 0.008862
3b Up-Right>Down-Left 0.005218962 4365 4128 0.007896
3c Left>Down 8.43794E-39 3465 2467 0.033249
3c Up>Right 8.28651E-06 3636 3277 0.01196
3c Up>Down 3.83662E-51 3636 2467 0.038946
3c Right>Down 5.54982E-27 3277 2467 0.026986
3c Up-Left>Down-Right 3.99451E-32 4817 3732 0.036147
3c Up-Left>Down-Left 8.8083E-26 4817 3846 0.032349
3c Up-Right>Down-Right 5.12149E-30 4776 3732 0.034781
3c Up-Right>Down-Left 6.58137E-24 4776 3846 0.030983
3d Left>Down 3.43395E-11 3290 2781 0.016958
3d Up>Right 0.0001006 3430 3128 0.010061
3d Up>Down 9.38458E-17 3430 2781 0.021622
3d Right>Down 3.36065E-06 3128 2781 0.011561
3d Up-Left>Down-Right 3.00716E-09 4616 4073 0.01809
3d Up-Left>Down-Left 7.27853E-10 4616 4052 0.01879
3d Up-Right>Down-Right 4.4512E-10 4646 4073 0.01909
3d Up-Right>Down-Left 1.00376E-10 4646 4052 0.019789
4c Left>Down 1.80173E-22 3452 2693 0.025287
4c Up>Right 0.001016395 3544 3288 0.008529
4c Up>Down 2.14947E-27 3544 2693 0.028352
4c Right>Down 7.53679E-15 3288 2693 0.019823
4c Up-Left>Down-Right 1.89419E-15 4608 3883 0.024154
4c Up-Left>Down-Left 5.4962E-17 4608 3845 0.02542
4c Up-Right>Down-Right 4.56254E-19 4703 3883 0.027319
4c Up-Right>Down-Left 8.71289E-21 4703 3845 0.028585
4d Up>Right 0.000758237 3387 3130 0.008562
4d Up>Down 2.3961E-06 3387 3020 0.012227
4d Up-Left>Down-Left 0.000806411 4434 4141 0.009761
4d Up-Right>Down-Right 0.002751673 4483 4223 0.008662
4d Up-Right>Down-Left 0.000120132 4483 4141 0.011394
5 Up-Right>Down-Left 0.007179405 4568 4336 0.007729
6 Up>Left 0.000185805 3168 2890 0.009262
6 Down>Left 0.001384885 3123 2890 0.007763
6 Up>Right 0.001689868 3168 2938 0.007663
6 Down-Left>Up-Left 0.007872249 4612 4382 0.007663
6 Down-Right>Up-Right 0.000636199 4604 4299 0.010161
6 Down-Left>Up-Right 0.000474106 4612 4299 0.010428
6a Up>Left 0.000185805 3168 2890 0.009262
6a Down>Left 0.001384885 3123 2890 0.007763
6a Up>Right 0.001689868 3168 2938 0.007663
6a Down-Left>Up-Left 0.007872249 4612 4382 0.007663
6a Down-Right>Up-Right 0.000636199 4604 4299 0.010161
6a Down-Left>Up-Right 0.000474106 4612 4299 0.010428
6b Up>Left 0.000185805 3168 2890 0.009262
6b Down>Left 0.001384885 3123 2890 0.007763
6b Up>Right 0.001689868 3168 2938 0.007663
6b Down-Left>Up-Left 0.007872249 4612 4382 0.007663
6b Down-Right>Up-Right 0.000636199 4604 4299 0.010161
6b Down-Left>Up-Right 0.000474106 4612 4299 0.010428
7 Up>Down 0.000490714 3146 2889 0.008562
7 Up-Left>Down-Right 0.001082933 4618 4327 0.009695
10 Up>Left 2.59842E-06 3539 3165 0.01246
10 Left>Down 2.07022E-15 3165 2570 0.019823
10 Up>Right 0.000186956 3539 3245 0.009795
10 Up>Down 1.14157E-35 3539 2570 0.032283
10 Right>Down 4.43725E-19 3245 2570 0.022488
10 Up-Left>Down-Right 1.54919E-41 5004 3747 0.041878
10 Up-Left>Down-Left 6.23473E-40 5004 3771 0.041078
10 Up-Right>Down-Right 7.46253E-40 4975 3747 0.040912
10 Up-Right>Down-Left 2.77489E-38 4975 3771 0.040112
11 Down>Left 4.74193E-05 3248 2940 0.010261
11 Down>Right 0.001986091 3248 3019 0.007629
11 Down-Right>Up-Left 1.12272E-12 4840 4173 0.022221
11 Down-Left>Up-Left 3.53391E-05 4545 4173 0.012393
11 Down-Right>Up-Right 5.23722E-12 4840 4193 0.021555
11 Down-Left>Up-Right 8.65349E-05 4545 4193 0.011727
11 Down-Right>Down-Left 0.00120259 4840 4545 0.009828
11a Down>Left 0.003005418 3171 2955 0.007196
11a Down>Right 0.003005418 3171 2955 0.007196
11a Down-Right>Up-Left 1.52452E-07 4712 4227 0.016158
11a Down-Left>Up-Left 1.53403E-06 4668 4227 0.014692
11a Down-Right>Up-Right 2.72161E-08 4712 4198 0.017124
11a Down-Left>Up-Right 3.14605E-07 4668 4198 0.015658
12 Left>Right 6.50018E-10 2903 2458 0.014825
12 Left>Down 2.01503E-10 2903 2445 0.015259
12 Up>Right 1.19323E-06 2801 2458 0.011427
12 Up>Down 4.71611E-07 2801 2445 0.01186
12 Up-Left>Up-Right 2.19387E-05 5241 4830 0.013693
12 Up-Left>Down-Right 4.49431E-16 5241 4449 0.026386
12 Up-Left>Down-Left 0.000243574 5241 4889 0.011727
12 Up-Right>Down-Right 3.98353E-05 4830 4449 0.012693
12 Down-Left>Down-Right 2.7632E-06 4889 4449 0.014659