def quantile(x, q):
    """Generate the q'th quantile of x
    Arguments:
        x: a numpy array
        q: the quantile of interest (a float)
    Returns:
        the element of x closest to the qth quantile.
    """
    if len(x.shape) != 1:
        return None
    x = x.tolist()
    x.sort()
    return x[int((len(x) - 1) * float(q))]