本文整理汇总了Python中scipy.stats.wilcoxon方法的典型用法代码示例。如果您正苦于以下问题:Python stats.wilcoxon方法的具体用法?Python stats.wilcoxon怎么用?Python stats.wilcoxon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类scipy.stats
的用法示例。
在下文中一共展示了stats.wilcoxon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_wilcoxon_tie
# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import wilcoxon [as 别名]
def test_wilcoxon_tie():
# Regression test for gh-2391.
# Corresponding R code is:
# > result = wilcox.test(rep(0.1, 10), exact=FALSE, correct=FALSE)
# > result$p.value
# [1] 0.001565402
# > result = wilcox.test(rep(0.1, 10), exact=FALSE, correct=TRUE)
# > result$p.value
# [1] 0.001904195
stat, p = stats.wilcoxon([0.1] * 10)
expected_p = 0.001565402
assert_equal(stat, 0)
assert_allclose(p, expected_p, rtol=1e-6)
stat, p = stats.wilcoxon([0.1] * 10, correction=True)
expected_p = 0.001904195
assert_equal(stat, 0)
assert_allclose(p, expected_p, rtol=1e-6)
示例2: main
# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import wilcoxon [as 别名]
def main(_):
stats = FLAGS.stats.split(',')
root = FLAGS.root
model_names = FLAGS.model_names.split(',')
data = {}
for m in model_names:
d = load_data(root, m)
merge_into(data, d)
print '\nLOADED %d models, %d examples' % (len(data['models']),
len(data['examples']))
if 'mean' in stats:
compute_mean(data)
if 'rank' in stats:
compute_rank(data)
if 'diff' in stats:
compute_diff(data)
if 'wilcoxon' in stats:
compute_wilcoxon(data)
print
示例3: compare_det_test
# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import wilcoxon [as 别名]
def compare_det_test(results_df, detector_name1, detector_name2, experiment=None):
se1 = get_sensivities(results_df, detector_name1, experiment)
if len(se1) < 2:
return 0
se2 = get_sensivities(results_df, detector_name2, experiment)
if len(se2) < 2:
return 0
l = min(len(se1),len(se2))
if (l < 20):
return None
#print("1:",se1[:l])
#print("2:",se2[:l])
try:
t,p = stats.wilcoxon(se1[:l],se2[:l])
return p
except:
return None
示例4: wilcoxon_test
# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import wilcoxon [as 别名]
def wilcoxon_test(v1,v2):# original metric: the smaller the more similar
result = stats.wilcoxon(v1, v2).statistic
if result != result:
result = 0
return 1/(math.sqrt(result)+1)
示例5: entroy_test
# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import wilcoxon [as 别名]
def entroy_test(v1,v2):#original metric: the smaller the more similar
result = stats.entropy(v1,v2)
result = stats.wilcoxon(v1, v2).statistic
if result != result:
result = 0
return result
示例6: spearmanr_test
# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import wilcoxon [as 别名]
def spearmanr_test(v1,v2):#original metric: the larger the more similar
result = stats.mstats.spearmanr(v1,v2).correlation
result = stats.wilcoxon(v1, v2).statistic
if result != result:
result = -1
return sigmoid(result)
示例7: pearsonr_test
# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import wilcoxon [as 别名]
def pearsonr_test(v1,v2):#original metric: the larger the more similar
result = stats.mstats.pearsonr(v1,v2)[0]
result = stats.wilcoxon(v1, v2).statistic
if result != result:
result = -1
return sigmoid(result)
示例8: symtest
# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import wilcoxon [as 别名]
def symtest(alpha, axis=None):
"""
Non-parametric test for symmetry around the median. Works by performing a
Wilcoxon sign rank test on the differences to the median.
H0: the population is symmetrical around the median
HA: the population is not symmetrical around the median
:param alpha: sample of angles in radian
:param axis: compute along this dimension, default is None
if axis=None, array is raveled
:return pval: two-tailed p-value
:return T: test statistics of underlying wilcoxon test
References: [Zar2009]_
"""
m = descriptive.median(alpha, axis=axis)
d = np.angle(np.exp(1j * m[np.newaxis]) / np.exp(1j * alpha))
if axis is not None:
oshape = d.shape[1:]
d2 = d.reshape((d.shape[0], int(np.prod(d.shape[1:]))))
T, pval = map(lambda x: np.asarray(x).reshape(
oshape), zip(*[stats.wilcoxon(dd) for dd in d2.T]))
else:
T, pval = stats.wilcoxon(d)
return pval, T
示例9: test_wilcoxon_bad_arg
# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import wilcoxon [as 别名]
def test_wilcoxon_bad_arg():
"""Raise ValueError when two args of different lengths are given or
zero_method is unknwon"""
assert_raises(ValueError, stats.wilcoxon, [1], [1,2])
assert_raises(ValueError, stats.wilcoxon, [1,2], [1,2], "dummy")
示例10: test_accuracy_wilcoxon
# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import wilcoxon [as 别名]
def test_accuracy_wilcoxon():
freq = [1, 4, 16, 15, 8, 4, 5, 1, 2]
nums = range(-4, 5)
x = np.concatenate([[u] * v for u, v in zip(nums, freq)])
y = np.zeros(x.size)
T, p = stats.wilcoxon(x, y, "pratt")
assert_allclose(T, 423)
assert_allclose(p, 0.00197547303533107)
T, p = stats.wilcoxon(x, y, "zsplit")
assert_allclose(T, 441)
assert_allclose(p, 0.0032145343172473055)
T, p = stats.wilcoxon(x, y, "wilcox")
assert_allclose(T, 327)
assert_allclose(p, 0.00641346115861)
# Test the 'correction' option, using values computed in R with:
# > wilcox.test(x, y, paired=TRUE, exact=FALSE, correct={FALSE,TRUE})
x = np.array([120, 114, 181, 188, 180, 146, 121, 191, 132, 113, 127, 112])
y = np.array([133, 143, 119, 189, 112, 199, 198, 113, 115, 121, 142, 187])
T, p = stats.wilcoxon(x, y, correction=False)
assert_equal(T, 34)
assert_allclose(p, 0.6948866, rtol=1e-6)
T, p = stats.wilcoxon(x, y, correction=True)
assert_equal(T, 34)
assert_allclose(p, 0.7240817, rtol=1e-6)
示例11: test_wilcoxon_bad_arg
# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import wilcoxon [as 别名]
def test_wilcoxon_bad_arg():
# Raise ValueError when two args of different lengths are given or
# zero_method is unknown.
assert_raises(ValueError, stats.wilcoxon, [1], [1, 2])
assert_raises(ValueError, stats.wilcoxon, [1, 2], [1, 2], "dummy")
示例12: test_wilcoxon_arg_type
# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import wilcoxon [as 别名]
def test_wilcoxon_arg_type():
# Should be able to accept list as arguments.
# Address issue 6070.
arr = [1, 2, 3, 0, -1, 3, 1, 2, 1, 1, 2]
_ = stats.wilcoxon(arr, zero_method="pratt")
_ = stats.wilcoxon(arr, zero_method="zsplit")
_ = stats.wilcoxon(arr, zero_method="wilcox")
示例13: test_wilcoxon_result_attributes
# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import wilcoxon [as 别名]
def test_wilcoxon_result_attributes():
x = np.array([120, 114, 181, 188, 180, 146, 121, 191, 132, 113, 127, 112])
y = np.array([133, 143, 119, 189, 112, 199, 198, 113, 115, 121, 142, 187])
res = stats.wilcoxon(x, y, correction=False)
attributes = ('statistic', 'pvalue')
check_named_results(res, attributes)
示例14: wilcoxon_similar_distribution
# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import wilcoxon [as 别名]
def wilcoxon_similar_distribution(self, column,
pvalue_threshold=0.05,
num_rounds=3):
p_value = permutation_test(
self.new_data[column],
self.historical_data[column],
method="approximate",
num_rounds=num_rounds,
func=lambda x, y: stats.wilcoxon(x, y).statistic,
seed=0)
if p_value < pvalue_threshold:
return False
return True
示例15: getActiveTF
# 需要导入模块: from scipy import stats [as 别名]
# 或者: from scipy.stats import wilcoxon [as 别名]
def getActiveTF(self,dTD,dTG,dMb):
# the idea : the targets for given TFs are signiciantly differenent between the fromNode and toNode
HGL=[item.upper() for item in self.GL]
pv_cut=1e-1
ATF=[]
FE=self.fromNode.getAvgEx()
TE=self.toNode.getAvgEx()
for i in dMb:
tfi=dMb[i]
tfi=[HGL.index(item) for item in tfi]
fe=[FE[item] for item in tfi]
te=[TE[item] for item in tfi]
#fe=[self.fromNode.E[item] for item in tfi]
#te=[self.toNode.E[item] for item in tfi]
#fe=reduce(lambda x,y:x+y, [[item.E[j] for item in self.fromNode.cells] for j in tfi])
#te=reduce(lambda x,y:x+y, [[item.E[j] for item in self.toNode.cells] for j in tfi])
#pdb.set_trace()
pv=wilcoxon(fe,te)[-1]
if pv<pv_cut:
ATF.append([pv,i])
ATF.sort()
return [item[1] for item in ATF]
#-------------------------------------------------------------------
# regresion model for each path