def quantile(a, prob):
    """
    Estimates the prob'th quantile of the values in a data array.
    Uses the algorithm of matlab's quantile(), namely:
        - Remove any nan values
        - Take the sorted data as the (.5/n), (1.5/n), ..., (1-.5/n) quantiles.
        - Use linear interpolation for values between (.5/n) and (1 - .5/n).
        - Use the minimum or maximum for quantiles outside that range.
    See also: scipy.stats.mstats.mquantiles
    """
a = np.asanyarray(a)
equavelent python command for quantile in matlab