Calculating 95th percentile with awk
awk
Solution
I am not sure if Excel does some kind of weighted percentile, but if you actually want one of the numbers that was in your original set, then your method should work correctly for rounding.
You can simplify a little bit like this, but it's the same thing.
sort -n input.txt | awk '{all[NR] = $0} END{print all[int(NR*0.95 - 0.5)]}'
Problem
I'm new in awk scripting and would like to have some help in calculating 95th percentile value for a file that consist of this data: ``` 0.0001357 0.000112 0.000062 0.000054 0.000127 0.000114 0.000136 ``` I tried: ``` cat filename.txt | sort -n | awk 'BEGIN{c=0} {total[c]=$1; c++;} END{print total[int(NR*0.95-0.5)]}' ``` but I dont seem to get the correct value when I compare it to excel.