code: public double[] rand() {
          double[] spt = new double[mu.length];
  
          for (int i = 0; i < mu.length; i++) {
              double u, v, q;
              do {
                  u = Math.random();
                  v = 1.7156 * (Math.random() - 0.5);
                  double x = u - 0.449871;
                  double y = Math.abs(v) + 0.386595;
                  q = x * x + y * (0.19600 * y - 0.25472 * x);
              } while (q > 0.27597 && (q > 0.27846 || v * v > -4 * Math.log(u) * u * u));
  
              spt[i] = v / u;
          }
  
          double[] pt = new double[sigmaL.nrows()];
  
          // pt = sigmaL * spt
          for (int i = 0; i < pt.length; i++) {
              for (int j = 0; j <= i; j++) {
                  pt[i] += sigmaL.get(i, j) * spt[j];
              }
          }
  
          Math.plus(pt, mu);
  
          return pt;
      }
docs: Generate a random multivariate Gaussian sample.