当前位置: 首页>>代码示例>>Python>>正文


Python stats.wilcoxon方法代码示例

本文整理汇总了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) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:20,代码来源:test_morestats.py

示例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 
开发者ID:google,项目名称:stereo-magnification,代码行数:24,代码来源:rank.py

示例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 
开发者ID:berndporr,项目名称:py-ecg-detectors,代码行数:19,代码来源:show_stats_plots.py

示例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) 
开发者ID:RoyZhengGao,项目名称:edge2vec,代码行数:7,代码来源:transition.py

示例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 
开发者ID:RoyZhengGao,项目名称:edge2vec,代码行数:8,代码来源:transition.py

示例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) 
开发者ID:RoyZhengGao,项目名称:edge2vec,代码行数:8,代码来源:transition.py

示例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) 
开发者ID:RoyZhengGao,项目名称:edge2vec,代码行数:8,代码来源:transition.py

示例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 
开发者ID:circstat,项目名称:pycircstat,代码行数:34,代码来源:tests.py

示例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") 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:7,代码来源:test_morestats.py

示例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) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:30,代码来源:test_morestats.py

示例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") 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:7,代码来源:test_morestats.py

示例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") 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:10,代码来源:test_morestats.py

示例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) 
开发者ID:Relph1119,项目名称:GraphicDesignPatternByPython,代码行数:8,代码来源:test_morestats.py

示例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 
开发者ID:EricSchles,项目名称:drifter_ml,代码行数:15,代码来源:columnar_tests.py

示例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 
开发者ID:phoenixding,项目名称:scdiff,代码行数:30,代码来源:scdiff.py


注:本文中的scipy.stats.wilcoxon方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。