code: def gen_gausprocess_se(ntrain, ntest, noise=1., lenscale=1., scale=1.,
                         xmin=-10, xmax=10):
      
  
      # Xtrain = np.linspace(xmin, xmax, ntrain)[:, np.newaxis]
      Xtrain = np.random.rand(ntrain)[:, np.newaxis] * (xmin - xmax) - xmin
      Xtest = np.linspace(xmin, xmax, ntest)[:, np.newaxis]
      Xcat = np.vstack((Xtrain, Xtest))
  
      K = scale * np.exp(-cdist(Xcat, Xcat, metric='sqeuclidean') /
                         (2 * lenscale**2))
      U, S, V = np.linalg.svd(K)
      L = U.dot(np.diag(np.sqrt(S))).dot(V)
      f = np.random.randn(ntrain + ntest).dot(L)
  
      ytrain = f[0:ntrain] + np.random.randn(ntrain) * noise
      ftest = f[ntrain:]
  
      return Xtrain, ytrain, Xtest, ftest
docs: Generate a random (noisy) draw from a Gaussian Process with a RBF kernel.