'``prctile(data, 50)`` returns the median, but p_vals can
also be a sequence.
Provides for small samples better values than matplotlib.mlab.prctile,
however also slower.'

@staticmethod
def prctile(data, p_vals=[0, 25, 50, 75, 100], sorted_=False):

    ps = ([p_vals] if np.isscalar(p_vals) else p_vals)
    if (not sorted_):
        data = sorted(data)
    n = len(data)
    d = []
    for p in ps:
        fi = (((p * n) / 100) - 0.5)
        if (fi <= 0):
            d.append(data[0])
        elif (fi >= (n - 1)):
            d.append(data[(-1)])
        else:
            i = int(fi)
            d.append(((((i + 1) - fi) * data[i]) + ((fi - i) * data[(i + 1)])))
    return (d[0] if np.isscalar(p_vals) else d)
