python spearman相关系数_Python spearman相关系数不匹配 .
所以我有一個數據集,它是分子豐度作為物理參數的函數,我想確定兩者之間的相互關系 . 這兩個參數都跨越了幾個數量級 .
因為兩者不是線性相關的,所以我選擇使用 scipy.stats.spearmanr 中的Spearman等級相關系數 . 但我的問題是結果有時沒有意義,我無法弄清楚我做錯了什么 .
下圖是圖,其中豐度被繪制為三個不同的時間(顏色) . 但奇怪的是,雖然黑線顯示豐度下降,因此負相關系數,但另外兩條線顯示正相關,盡管它們與黑線沒有那么不同!
這是我使用的代碼,我排除了代碼的化妝品部分 .
for t in range(0, len(times)):
ax.loglog(parameter, abunds[t], color=colors[t])
corr_coeffs[t] = stats.spearmanr(np.log10(parameter),np.log10(abundances[t,:])
patches.append(mpatches.Patch(color=colors[t], label="r=" + str(("%.2f"%corr_coeffs[t,0])) + ", p=" + str(("%.2f"%corr_coeffs[t,1])) + " | " + time_label[t]))
legend = plt.legend(handles=patches, fontsize="large", loc='best')
plt.savefig('example.png')
如果有人能向我解釋這種奇怪的行為,我將非常感激 .
總結
以上是生活随笔為你收集整理的python spearman相关系数_Python spearman相关系数不匹配 .的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: python打卡记录去重_Python笔
- 下一篇: pythonint切片_python-切