Załóżmy, że percentyl x wynosi 60%, co oznacza, że 80% wyników w a jest poniżej x.
Parametry:
arr: [array_like] input array.
score: [int or float] Wynik w porównaniu z elementami tablicy.
rodzaj: [ opcjonalnie] „ranga”, „słaba”, „ścisła”, „średnia”.Wyniki: Percentyl wyników względem elementu tablicy.
Kod nr 1:
#%
z
scipy
import
statystyki
import
numpy as np
# tablica 1D
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
))
Wyjście:
arr: [20, 2, 7, 1, 7, 7, 34] Percetyl z 7: 57.1428571429 Percetyl z 34: 100.0 Percetyl z 2: 28.5714285714