Skip to content

Instantly share code, notes, and snippets.

@threecifanggen
Last active October 12, 2022 06:24
Show Gist options
  • Select an option

  • Save threecifanggen/1c7bd10ec67652f08c84cc30c19730eb to your computer and use it in GitHub Desktop.

Select an option

Save threecifanggen/1c7bd10ec67652f08c84cc30c19730eb to your computer and use it in GitHub Desktop.
[单样本Wilcoxon检验] 用`Python`实现的Wilcoxon检验 #wilcoxon #python #one-sample-test
"""
### 例子
正常男性尿检中位数$M_0$为$0.33\mu mol/L$,抽取工厂血铅含量如下,求是否符合正常。
"""
import statsmodels.stats as sts
M_0 = 0.33
M = [0.29, 0.31, 0.34, 0.37, 0.38, 0.41, 0.47, 0.52, 0.69, 0.72, 0.73, 0.77, 0.78, 0.80, 0.83, 0.92, 0.95, 0.97]
sts.descriptivestats.sign_test(M, M_0) # (7.0, 0.001312255859375) 有显著差异
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment