How to calculate what percentage of X value is there in the file?

Input File:

5081
2058
175
8282
2358
7347
6612
3459

END OF INPUT FILE

I need to know how to calculate minimum,maximum,average of the values in the file and also what percentage is the values over some user defined value for example 1000 and what percentage of value is over 5000.

By using the following command mentioned below i was able to find the minimum ,maximum and average but having problem in calculatung perctangae.

awk 'NR==1{min=$1;max=$1;sum+=$1;next}{if ($1<min) min=$1;if ($1>max)
  max=$1;sum+=$1}END{print "min: "min", max: "max",NR: "NR", avg: "sum/NR}' INPUT FILE
awk ' BEGIN { max=sum=0; th=fv=0; } NR==1 { min=$1; } {
 val=$1;
 sum+=val;
 if(val<min) { min=val; }
 if(val>max) { max=val; }
 if(val>1000) { th++; }
 if(val>5000) { fv++; }
 } END {
 printf "Min: %d Max: %d Avg: %d 1000 per: %d 5000 per: %d\n", min, max, (sum/NR), (th/NR * 100), (fv/NR * 100);
} ' filename

Here is a version where you can Set limits for F1 and F2 on the command line:

awk -vF1=1000 -vF2=5000 'FNR==1 {min=$1}
{
 sum+=$1;
 if($1<min) min=$1
 if($1>max) max=$1
 th+=($1>F1)
 fv+=($1>F2)
}
END {
 printf "Min: %d Max: %d Avg: %d above %d: %d%% above %d: %d%%\n", min, max, sum/NR, F1, th/NR*100, F2, fv/NR * 100
} ' infile