About this percentile calculator
Sort the data and find position h = (n − 1) × p ÷ 100 counting from 0; interpolate between the neighbours. For 15, 20, 35, 40, 50 and p = 40: h = 1.6, between 20 and 35, so 20 + 0.6 × 15 = 29. The nearest-rank method instead takes the value at rank ⌈p × n ÷ 100⌉ = 2: 20. Percentile rank goes the other way: 35 has 2 values below it and 1 equal, (2 + 0.5) ÷ 5 = 50%.