docs: public double compute(double[] x, double[] grad) {
      
      double val = 0.0;
  
      switch (type) {
        case NULL:
          return val;
  
        case QUADRATIC:
          for (int i = 0; i < x.length; i++) {
            val += x[i] * x[i] / 2.0 / sigmaSq;
            grad[i] += x[i] / sigmaSq;
          }
          return val;
  
        case HUBER:
          // P.J. Huber. 1973. Robust regression: Asymptotics, conjectures and
          // Monte Carlo. The Annals of Statistics 1: 799-821.
          // See also:
          // P. J. Huber. Robust Statistics. John Wiley & Sons, New York, 1981.
          for (int i = 0; i < x.length; i++) {
            if (x[i] < -epsilon) {
              val += (-x[i] - epsilon / 2.0) / sigmaSq;
              grad[i] += -1.0 / sigmaSq;
            } else if (x[i] < epsilon) {
              val += x[i] * x[i] / 2.0 / epsilon / sigmaSq;
              grad[i] += x[i] / epsilon / sigmaSq;
            } else {
              val += (x[i] - epsilon / 2.0) / sigmaSq;
              grad[i] += 1.0 / sigmaSq;
            }
          }
          return val;
  
        case QUARTIC:
          for (int i = 0; i < x.length; i++) {
            val += (x[i] * x[i]) * (x[i] * x[i]) / 2.0 / sigmaQu;
            grad[i] += x[i] / sigmaQu;
          }
          return val;
  
        case ADAPT:
          double[] newX = ArrayMath.pairwiseSubtract(x, means);
          val += otherPrior.compute(newX, grad);
          return val;
  
        case COSH:
          double norm = ArrayMath.norm_1(x) / sigmaSq;
          double d;
          if (norm > 30.0) {
            val = norm - Math.log(2);
            d = 1.0 / sigmaSq;
          } else {
            val = Math.log(Math.cosh(norm));
            d = (2 * (1 / (Math.exp(-2.0 * norm) + 1)) - 1.0) / sigmaSq;
          }
          for (int i=0; i < x.length; i++) {
            grad[i] += Math.signum(x[i]) * d;
          }
          return val;
        case MULTIPLE_QUADRATIC:
  //        for (int i = 0; i < x.length; i++) {
  //          val += x[i] * x[i]* 1/2 * regularizationHyperparameters[i];
  //          grad[i] += x[i] * regularizationHyperparameters[i];
  //        }
          
          for (int i = 0; i < x.length; i++) {
            val += x[i] * x[i] / 2.0 / sigmaSqM[i];
            grad[i] += x[i] / sigmaSqM[i];
          }
          
          
          return val;
        default:
          throw new RuntimeException("LogPrior.valueAt is undefined for prior of type " + this);
      }
    }