了解计算百分位数的细微差别

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

使用

numpy
计算百分位数时,我看到一些作者使用:

Q1, Q3 = np.percentile(X, [25, 75])

这对我来说很清楚。但是,我也看到其他人使用:

loss = np.percentile(X, 4)

我假设 4 意味着将 100 分成 4 个百分位数,但这里的损失是如何计算的(即,在第二种情况下)?

python numpy percentile
1个回答
3
投票

我不知道你在哪里找到第二个案例,但它是不正确的(或被误解了)。

np.percentile(X, 4)
简单地计算第 4 个百分位数。

X = np.arange(0, 101)

np.percentile(X, [25, 75])
# array([25., 75.])

np.percentile(X, 4)
# 4.0
© www.soinside.com 2019 - 2024. All rights reserved.