code: public static GaussianRadialBasis learnGaussianRadialBasis(double[][] x, double[][] centers) {
          int k = centers.length;
          KMeans kmeans = new KMeans(x, k, 10);
          System.arraycopy(kmeans.centroids(), 0, centers, 0, k);
  
          double r0 = 0.0;
          for (int i = 0; i < k; i++) {
              for (int j = 0; j < i; j++) {
                  double d = Math.distance(centers[i], centers[j]);
                  if (r0 < d) {
                      r0 = d;
                  }
              }
          }
  
          r0 /= Math.sqrt(2*k);
          return new GaussianRadialBasis(r0);
      }
docs: Learns Gaussian RBF function and centers from data. The centers are
  chosen as the centroids of K-Means. Let d<sub>max</sub> be the maximum
  distance between the chosen centers, the standard deviation (i.e. width)
  of Gaussian radial basis function is d<sub>max</sub> / sqrt(2*k), where
  k is number of centers. This choice would be close to the optimal
  solution if the data were uniformly distributed in the input space,
  leading to a uniform distribution of centroids.
  @param x the training dataset.
  @param centers an array to store centers on output. Its length is used as k of k-means.
  @return a Gaussian RBF function with parameter learned from data.