假設x百分位數為60%,表示a中80%的分數低於x。
參數:
arr: [array_like] 輸入數組。
score: [int or float] 與數組中元素比較的分數。
kind: [可選] `rank`, `weak`, `strict`, `mean`。結果:相對於數組元素的分數百分比。
blockquote>代碼#1:
#%
from
scipy
import
stats
import
numpy as np
# 一維數組
arr
=
[
20
,
2
,
7
,
1
,
7
,
7
,
34
]
(
"arr:"
, arr)
(
" Percetile of 7: "
, stats.percentileofscore (arr,
7
))
(
"Percetile of 34:"
, stats.percentileofscore (arr,
34
))
(
"Percetile of 2:"
, stats.percentileofscore (arr,
2
))
退出:
arr: [20, 2, 7, 1, 7, 7, 34] 7 分位數:57.1428571429 34 分位數:100.0 2 分位數:28.5714285714