英文:
Understanding the subtle difference in calculating percentile
问题
使用numpy
计算百分位时,我看到一些作者使用以下方式:
Q1, Q3 = np.percentile(X, [25, 75])
这对我来说很清楚。然而,我也看到其他人使用以下方式:
loss = np.percentile(X, 4)
我认为这里的4表示将100分成4个百分位,但在这种情况下如何计算损失(即在第二种情况下)?
英文:
When calculating the percentile using numpy
, I see some authors use:
Q1, Q3 = np.percentile(X, [25, 75])
which is clear to me. However, I also see others use:
loss = np.percentile(X, 4)
I presume 4 implies dividing the 100 into 4 percentiles but how the loss is calculated here (i.e., in the second case)?
答案1
得分: 4
np.percentile(X, 4)
只是计算第4百分位数。
英文:
I don't know where you found the second case but it's incorrect (or misinterpreted).
np.percentile(X, 4)
simply calculates the 4th percentile.
X = np.arange(0, 101)
np.percentile(X, [25, 75])
# array([25., 75.])
np.percentile(X, 4)
# 4.0
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论