def median_trick(X):
    """
        median trick for computing the bandwith for kernel regression.
    """
    N = len(X)
    perm = np.random.choice(N, N, replace=False)
    dsample = X[perm]
    pd = scipy.spatial.distance.pdist(dsample)
    sigma = np.median(pd)
    return sigma

        median trick for computing the bandwith for kernel regression.
    
tools/gp_interpolation.py