scipy 中的 st.ttest_ind 返回 p 值为 0.0

问题描述 投票:0回答:1

我正在尝试进行假设检验,但得到的 p 值为 0。我可以理解它是否真的很小,但 0.0 让我相信存在错误。这是我的代码:

results = st.ttest_ind(
        ultimate_users['monthly_profit'], 
        surf_users['monthly_profit'], nan_policy = 'omit')

print('p-value: ', results.pvalue)

输出: p 值:0.0

python pandas scipy p-value hypothesis-test
1个回答
0
投票

不一定有错误。如果 p 值小于最小双精度浮点数,则它会“下溢”,并且您会得到零。这不会是您的代码或 SciPy 中的错误;这只是浮点运算的一个基本限制。 如果样本量很大,则样本均值差异不大即可获得零 p 值。

import numpy as np from scipy import stats rng = np.random.default_rng(83469358365936) x = rng.random(1000) stats.ttest_ind(x, x + 1) # TtestResult(statistic=-76.66392731424226, pvalue=0.0, df=1998.0)

© www.soinside.com 2019 - 2024. All rights reserved.