docs: double betaFunction(List<Double> x, int type) {
      double beta;
      beta = 0;
      int dim = x.size();
  
      if (dim == 0) {
        beta = 0;
      }
  
      if (type == 1) {
        beta = 0;
        for (int i = 0; i < dim; i++) {
          beta += x.get(i) * x.get(i);
        }
        beta = 2.0 * beta / dim;
      }
  
      if (type == 2) {
        beta = 0;
        for (int i = 0; i < dim; i++) {
          beta += Math.sqrt(i + 1) * x.get(i) * x.get(i);
        }
        beta = 2.0 * beta / dim;
      }
  
      if (type == 3) {
        double sum = 0, xx;
        for (int i = 0; i < dim; i++) {
          xx = 2 * x.get(i);
          sum += (xx * xx - Math.cos(4 * Math.PI * xx) + 1);
        }
        beta = 2.0 * sum / dim;
      }
  
      if (type == 4) {
        double sum = 0, prod = 1, xx;
        for (int i = 0; i < dim; i++) {
          xx = 2 * x.get(i);
          sum += xx * xx;
          prod *= Math.cos(10 * Math.PI * xx / Math.sqrt(i + 1));
        }
        beta = 2.0 * (sum - 2 * prod + 2) / dim;
      }
  
      return beta;
    }