Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Percentile on Fortran

Status
Not open for further replies.

Ahn210

Technical User
Jun 18, 2013
11
Hello-

Can someone teach me how to get percentile value given a sorted array data?

Data
2.56
2.44
1.2
0.99
0.76
0.36
0.35
0.32
0.22
0.11
0.09
0.031

I wish to find 70th and 30th percentile value
(0.921 // 0.25 got from excel)


 
IMO: You have population of n=12 data values
Then 30 percentile is quantile for p=0.3; n*p = 12*0.3 = 3.6 => rounded up = 4, i.e. 4th element in the population, i.e. 0.99

Similarly, 70 precentile is 0.7 quantile: n*p = 12*0.70 = 8.4 => rounded up = 9, i.e. 9th element in the populatiom, i.e. 0.22
 
Here is the better link which explains Excel interpolation formula:

For example - according to the formula given above:
70th percentile:
N=12, P = 70, n = P *(N-1)/100 + 1 = 70*11/100 + 1 = 8.7 = 8 + 0.7
Then v[sub]70[/sub] = v[sub]8[/sub] + 0.7*(v[sub]9[/sub] - v[sub]8[/sub]) = 0.32 + 0.7*(0.22 - 0.32) = 0.25

30th percentile:
N=12, P = 30, n = P *(N-1)/100 + 1 = 30*11/100 + 1 = 4.3 = 4 + 0.3
Then v[sub]30[/sub] = v[sub]4[/sub] + 0.3*(v[sub]5[/sub] - v[sub]4[/sub]) = 0.99 + 0.3*(0.76 - 0.99) = 0.921
 
To mikrom
Thanks for your reply; I always appreciate your posts! explanation on excel percentile was what I needed to apply that on fortran.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top