In statistics, a percentile (or centile) is the value of a variable below which a certain percent of observations fall.
Questions tagged [percentile]
739 questions
290
votes
12 answers
How do I calculate percentiles with python/numpy?
Is there a convenient way to calculate percentiles for a sequence or single-dimensional numpy array?
I am looking for something similar to Excel's percentile function.
I looked in NumPy's statistics reference, and couldn't find this. All I could…

Uri
- 88,451
- 51
- 221
- 321
71
votes
3 answers
Eliminating all data over a given percentile
I have a pandas DataFrame called data with a column called ms. I want to eliminate all the rows where data.ms is above the 95% percentile. For now, I'm doing this:
limit = data.ms.describe(90)['95%']
valid_data = data[data['ms'] < limit]
which…

Roy Smith
- 2,039
- 3
- 20
- 27
53
votes
12 answers
Weighted percentile using numpy
Is there a way to use the numpy.percentile function to compute weighted percentile? Or is anyone aware of an alternative python function to compute weighted percentile?
thanks!

user308827
- 21,227
- 87
- 254
- 417
53
votes
5 answers
Calculating percentile of dataset column
A quick one for you, dearest R gurus:
I'm doing an assignment and I've been asked, in this exercise, to get basic statistics out of the infert dataset (it's in-built), and specifically one of its columns, infert$age.
For anyone not familiar with the…

Dimitris Sfounis
- 2,400
- 4
- 31
- 46
51
votes
8 answers
Percentiles of Live Data Capture
I am looking for an algorithm that determines percentiles for live data capture.
For example, consider the development of a server application.
The server might have response times as follows:
17 ms
33 ms
52 ms
60 ms
55 ms
etc.
It is useful to…

Jason Kresowaty
- 16,105
- 9
- 57
- 84
44
votes
5 answers
matplotlib: disregard outliers when plotting
I'm plotting some data from various tests. Sometimes in a test I happen to have one outlier (say 0.1), while all other values are three orders of magnitude smaller.
With matplotlib, I plot against the range [0, max_data_value]
How can I just zoom…

Ricky Robinson
- 21,798
- 42
- 129
- 185
41
votes
10 answers
Map each list value to its corresponding percentile
I'd like to create a function that takes a (sorted) list as its argument and outputs a list containing each element's corresponding percentile.
For example, fn([1,2,3,4,17]) returns [0.0, 0.25, 0.50, 0.75, 1.00].
Can anyone please either:
Help me…

Jubbles
- 4,450
- 8
- 35
- 47
38
votes
2 answers
nth percentile calculations in postgresql
I've been surprisingly unable to find an nth percentile function for postgresql.
I am using this via mondrian olap tool so i just need an aggregate function which returns a 95th percentile.
I did find this…

Codek
- 5,114
- 3
- 24
- 38
37
votes
3 answers
Percentile calculation
I want to mimic the Excel equivalent PERCENTILE function in C# (or in some pseudo code). How can I do that? The function should take two arguments where the first is a list of values and the second is for what percentile the function should…

picknick
- 3,897
- 6
- 33
- 48
37
votes
6 answers
Fast algorithm for repeated calculation of percentile?
In an algorithm I have to calculate the 75th percentile of a data set whenever I add a value. Right now I am doing this:
Get value x
Insert x in an already sorted array at the back
swap x down until the array is sorted
Read the element at position…

martinus
- 17,736
- 15
- 72
- 92
34
votes
4 answers
How to get median and quartiles/percentiles of an array in JavaScript (or PHP)?
This question is turned into a Q&A, because I had struggle finding the answer, and think it can be useful for others
I have a JavaScript array of values and need to calculate in JavaScript its Q2 (50th percentile aka MEDIAN), Q1 (25th percentile)…

philippe
- 1,877
- 2
- 20
- 25
28
votes
4 answers
Is it possible to draw a boxplot given the percentile values instead of the original inputs?
From what I can see, boxplot() method expects a sequence of raw values (numbers) as input, from which it then computes percentiles to draw the boxplot(s).
I would like to have a method by which I could pass in the percentiles and get the…

Alex Averbuch
- 3,245
- 5
- 33
- 44
24
votes
8 answers
Calculating percentile rank in MySQL
I have a very big table of measurement data in MySQL and I need to compute the percentile rank for each and every one of these values. Oracle appears to have a function called percent_rank but I can't find anything similar for MySQL. Sure I could…

lhahne
- 5,909
- 9
- 33
- 40
21
votes
3 answers
Computing Percentiles In BigQuery
I am using BigQuery, and I need to compute the 25th, 50th, and 75th percentile of a column of a dataset.
For example, how can I get the aforementioned numbers using BigQuery and STANDARD SQL. I have looked at the PERCENT_RANK, RANK, and NTILE…

Praangrammer
- 219
- 1
- 2
- 4
21
votes
2 answers
How to find Nth percentile with SQLite?
I'll like to find Nth percentile.
for example: table: htwt; columns: name, gender, height, weight
result:
| gender | 90% height | 90% weight |
| male | 190 | 90 |
| female | 180 | 80 |

Eric Tan
- 243
- 1
- 2
- 5