gpt4 book ai didi

python - 何时使用 np.quantile 和 np.percentile?

转载 作者:行者123 更新时间:2023-12-04 12:02:54 25 4
gpt4 key购买 nike

我试图区分 np.quantile() 的场景或 np.percentile()应该使用。

>>> import numpy as np
>>> a = np.array([[10, 7, 4], [3, 2, 1]])
>>> np.quantile(a, 0.5)
3.5
>>> np.percentile(a, 50)
3.5

他们都给出相同的结果并调用 _quantile_unchecked()在他们的实现中。

什么是最好的用例?

最佳答案

它们是等价的。如果您希望从 [0, 1] 中指定 q,请使用 np.quantile。对于 [0, 100],使用 np.percentile。

文档:https://docs.scipy.org/doc/numpy/reference/generated/numpy.percentile.html

关于python - 何时使用 np.quantile 和 np.percentile?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55379220/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com