def percentile(self, histogram, bins, percent):
    """ Calculate the <<percent>> percentile of the histogram """
    
    # normalize the histogram
    hist_norm = np.zeros(histogram.shape)
    
    hist_sum = 0
    for binval in histogram:
      hist_sum += binval
    
    for i, binval in enumerate(histogram):
      hist_norm[i] = histogram[i] / hist_sum

    # compute the percentile using the normalized histogram
    bin_sum = 0
    i = 0
    pfloat = percent * 0.01 
    while bin_sum < pfloat and i < hist_norm.shape[0] + 1:
      bin_sum += hist_norm[i]
      i += 1 

    return bins[i+1]
dataset/ETHPy150Open neurodata/ndstore/scripts/imghist16.py/ImgHist.percentile/original