协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
ksd_bootstrap_gof【开发与工程】Calibrate a KSD U-statistic goodness-of-fit test with the centered multinomial bootstrap for degenerate U-statistics.
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
Use this skill when you already have a pairwise Stein kernel matrix and need the paper's KSD-U goodness-of-fit decision. The skill implements Algorithm 1's centered multinomial bootstrap, which is designed for the degenerate U-statistic null distribution.
Do not use this skill for ordinary non-degenerate bootstrap tests, V-statistic-only diagnostics, or linear-time KSD calibration.
stein_matrix: finite square matrix U where U[i,j] = u_q(x_i, x_j).alpha: significance level, usually 0.05.num_bootstrap: bounded number of bootstrap replicates.seed: integer random seed for reproducibility.ksd_u: unbiased KSD U-statistic.scaled_observed: n * ksd_u.bootstrap_scaled: bootstrap null samples.p_value: fraction of bootstrap statistics greater than the observed statistic.reject: boolean decision p_value < alpha.n with uniform category probabilities.(w_i - 1/n) before forming pairwise products.> tail rule.Run:
python tests/test_ksd_bootstrap_gof.py
The tests cover U-statistic calculation, reproducibility, and rejection behavior for a strongly positive Stein matrix.
Refinement invariant: treat multinomial draws as empirical probabilities before centering. For a draw count count_i, Equation (16) is implemented as (count_i / n - 1 / n), not raw count_i - 1 / n; raw counts make the bootstrap null too wide and suppress valid KSD-U rejections.