理解计算百分位数中的微妙差异

huangapple go评论108阅读模式
英文:

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

huangapple
  • 本文由 发表于 2023年3月7日 21:31:17
  • 转载请务必保留本文链接:https://go.coder-hub.com/75662625.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定