📜  sciPy stats.percentileofscore() | Python

📅  最后修改于: 2022-05-13 01:54:46.842000             🧑  作者: Mango

sciPy stats.percentileofscore() | Python

scipy.stats.percentileofscore(a, score, kind='rank')函数帮助我们计算分数相对于分数列表的百分位排名。
假设 x 的百分位数是 60%,这意味着 a 中 80% 的分数低于 x。

代码#1:

Python3
# percentileofscore
from scipy import stats
import numpy as np
 
# 1D array 
arr = [20, 2, 7, 1, 7, 7, 34]
print("arr : ", arr) 
 
print ("\nPercentile of 7  : ", stats.percentileofscore(arr, 7))
 
print ("\nPercentile of 34 : ", stats.percentileofscore(arr, 34))
 
print ("\nPercentile of 2  : ", stats.percentileofscore(arr, 2))


输出:

arr :  [20, 2, 7, 1, 7, 7, 34]

Percetile of 7  :  57.1428571429

Percetile of 34 :  100.0

Percetile of 2  :  28.5714285714