code: public INDArray reducedBasis(double variance) {
          INDArray vars = Transforms.pow(eigenvalues, -0.5, true);
          double res = vars.sumNumber().doubleValue();
          double total = 0.0;
          int ndims = 0;
          for (int i = 0; i < vars.columns(); i++) {
              ndims++;
              total += vars.getDouble(i);
              if (total / res > variance)
                  break;
          }
          INDArray result = Nd4j.create(eigenvectors.rows(), ndims);
          for (int i = 0; i < ndims; i++)
              result.putColumn(i, eigenvectors.getColumn(i));
          return result;
      }
docs: Return a reduced basis set that covers a certain fraction of the variance of the data
  @param variance The desired fractional variance (0 to 1), it will always be greater than the value.
  @return The basis vectors as columns, size <i>N</i> rows by <i>ndims</i> columns, where <i>ndims</i> is less than or equal to <i>N</i>