code: private static double[][] histogram(double[] data, int k, boolean prob) {
          double[][] hist = smile.math.Histogram.histogram(data, k);
  
          // The number of bins may be extended to cover all data.
          k = hist[0].length;
          double[][] freq = new double[k][2];
          for (int i = 0; i < k; i++) {
              freq[i][0] = (hist[0][i] + hist[1][i]) / 2.0;
              freq[i][1] = hist[2][i];
          }
  
          if (prob) {
              double n = data.length;
              for (int i = 0; i < k; i++) {
                  freq[i][1] /= n;
              }
          }
  
          return freq;
      }
docs: Generate the histogram of k bins.
  
  @param k the number of bins.