【发布时间】:2019-12-27 04:29:00
【问题描述】:
我正在尝试为我的指标(spearman)计算一个 p 值,我试图概括该方法,以便它可以与其他指标一起使用(而不是依赖于 scipy.stats.spearmanr)。
如何从这个分布中生成一个点的 p 值?
该方法是否适用于非正态分布?这是正态分布的,如果我采样超过 100 个点,可能会更多。
此帖需要µ=0 ,std=1Convert Z-score (Z-value, standard score) to p-value for normal distribution in Python
from scipy import stats
import seaborn as sns
import numpy as np
import matplotlib.pyplot as plt
data = np.asarray([0.027972027972027972, -0.2802197802197802, -0.21818181818181817, 0.3464285714285714, 0.15, 0.34065934065934067, -0.3216783216783217, 0.08391608391608392, -0.03496503496503497, -0.2967032967032967, 0.09090909090909091, 0.11188811188811189, 0.1181818181818182, -0.4787878787878788, -0.6923076923076923, -0.05494505494505495, 0.19090909090909092, 0.3146853146853147, -0.42727272727272725, 0.06363636363636363, 0.1978021978021978, 0.12142857142857141, 0.10303030303030303, 0.23214285714285712, -0.5804195804195805, 0.013986013986013986, 0.02727272727272727, 0.5659340659340659, 0.06363636363636363, -0.503030303030303, -0.2867132867132867, 0.07252747252747253, -0.13736263736263737, 0.21212121212121213, -0.09010989010989011, -0.2517482517482518, -0.17482517482517484, -0.3706293706293707, 0.15454545454545454, 0.01818181818181818, 0.17582417582417584, 0.3230769230769231, -0.09642857142857142, -0.5274725274725275, -0.23626373626373626, -0.2692307692307692, -0.2857142857142857, -0.19999999999999998, -0.489010989010989, -0.15454545454545454, 0.38461538461538464, 0.6, 0.37762237762237766, -0.0029411764705882353, -0.06993006993006994, -0.19999999999999998, 0.38181818181818183, 0.05454545454545455, -0.03296703296703297, 0.17272727272727273, -0.13986013986013987, -0.08241758241758242, -0.34545454545454546, 0.5252747252747253, 0.10303030303030303, 0.16783216783216784, -0.36363636363636365, -0.42857142857142855, 0.12727272727272726, -0.18181818181818182, -0.10439560439560439, -0.6083916083916084, -0.1956043956043956, 0.13846153846153847, -0.48951048951048953, -0.18881118881118883, 0.7362637362637363, -0.19090909090909092, 0.4909090909090909, 0.37142857142857144, -0.3090909090909091, -0.1098901098901099, 0.15151515151515152, -0.13636363636363635, -0.5494505494505495, 0.44755244755244755, 0.04895104895104896, -0.37142857142857144, 0.01098901098901099, 0.08131868131868132, 0.2571428571428571, -0.3076923076923077, 0.24545454545454545, 0.06043956043956044, 0.06764705882352941, 0.02727272727272727, -0.07252747252747253, 0.21818181818181817, -0.03846153846153846, 0.48571428571428577])
query_value = -0.44155844155844154
with plt.style.context("seaborn-white"):
fig, ax = plt.subplots()
sns.distplot(data, rug=True, color="teal", ax=ax)
ax.set_xlabel("$x$", fontsize=15)
ax.axvline(query_value, color="black", linestyle=":", linewidth=1.618, label="Query: %0.5f"%query_value)
ax.legend()
# Normal Test
print(stats.normaltest(data))
# Fit the data
params = stats.norm.fit(data)
# Generate the distribution
distribution = stats.norm(*params)
distribution
【问题讨论】:
-
从你的文字看不出,正态分布的点值、均值和sd是多少?另外,您是要估计密度还是累积?
-
这些是从 -1 到 1 的相关值。我正在尝试确定我的点值是否具有统计意义。我的理解是,我测量低于我的值(-0.44)和高于(0.44)的出现次数,然后将其除以排列总数(N = 100)。但是,这将是一个概率。是否可以使用 scipy 分布和点值来确定一个值是否显着?
-
你提到了一些新的信息,现在你没有包含在问题中,这是一个置换测试吗?
-
是的。抱歉,我漏掉了。
标签: python scipy statistics distribution p-value