I have looked this answer which explains how to compute the value of a specific percentile, and this answer which explains how to compute the percentiles that correspond to each element. Using the first solution, I can compute the value and scan the original array to find the index. Using the second solution, I can scan the entire output array for the percentile I'm looking for. However, both require an additional scan if I want to know the index (in the original array) that corresponds to a particular percentile (or the index containing the element closest to that index). Is there is more direct or built-in way to get the index which corresponds to a percentile? Note: My array is not sorted and I want the index in the original, unsorted array. Continue reading...