def _pval_from_histogram(T, H0, tail):
"""Get p-values from stats values given an H0 distribution
For each stat compute a p-value as percentile of its statistics
within all statistics in surrogate data
"""
if tail not in [-1, 0, 1]:
raise ValueError('invalid tail parameter')
# from pct to fraction
if tail == -1: # up tail
pval = np.array([np.sum(H0 <= t) for t in T])
elif tail == 1: # low tail
pval = np.array([np.sum(H0 >= t) for t in T])
else: # both tails
pval = np.array([np.sum(abs(H0) >= abs(t)) for t in T])
pval = (pval + 1.0) / (H0.size + 1.0) # the init data is one resampling
return pval
cluster_level.py 文件源码
python
阅读 28
收藏 0
点赞 0
评论 0
评论列表
文章目录