Solved by tom in post #2 
              
              
                Hi Ali, 
if your values are 8 or 16 bit integers (which is quite common), I’d probably just compute a histogram. 
If they are not, you could do this iteratively: Quantize to 8 bits by rounding down and up (keeping statistics for both rounded-down and rounded-up). Then you know the 5% percentile is b…