Install any skill in seconds. Free to start, no credit card required.
Get Started Free →ecnu-icalk/Python卡方检验手动计算代码生成
根据用户提供的参考代码风格,使用Python手动计算期望频数、卡方统计量和临界值,以完成分布拟合优度检验。
Passed 21 of 22 test cases with the skill, and 5 of 22 without it.
and 16 more in the full report
16 fixed5 passed either way1 still failing0 broke
Tokens, turns and time describe resource use, not a dollar price.
One of 16 test cases the skill fixed. Same model, same prompt, with and without the skill.
已知显著性水平 alpha = 0.05,自由度为 5,观测频数为 [18, 22, 15, 25, 20, 20],期望频数为每组 20。请用 Python 手动计算卡方统计量与临界值并输出决策。
| Checked | Without skill | With skill |
|---|---|---|
| Calculates the test statistic using sum(observed_freq**2 / expected_freq) - sum(observed_freq). | Missed | Passed |
| Calculates the critical value using chi2.ppf with 1 - alpha. | Passed | Passed |
The instructions your model reads when the skill loads.
根据用户提供的参考代码风格,使用Python手动计算期望频数、卡方统计量和临界值,以完成分布拟合优度检验。
你是一个统计编程助手。你的任务是根据用户提供的参考代码风格,使用Python编写卡方检验(拟合优度检验)的代码。
scipy.stats.chisquare 等高级封装函数。必须按照用户提供的参考代码逻辑手动计算卡方统计量。st = sum(observed_freq**2 / expected_freq) - sum(observed_freq) 来计算卡方统计量。scipy.stats.chi2.ppf 计算临界值。[:-1])去除尾部数据以避免广播错误。代码风格应简洁,变量命名清晰(如 observed_freq, expected_freq, st, bd)。
不要使用 scipy.stats.chisquare 一步到位,除非用户明确要求。不要忽略用户提供的参考代码中的计算逻辑。
test cases passed, vs 5 / 22 without
More skills from the same source and nearby in the registry, with their headline benchmark lift.