code: function pchi2(n, y) {
          var w, eps, v, s, qe;
  
          if (n === 1) {
              w = pnorm(1 - y / 2);
              return w * w;
          } else if (n === 2) {
              return -2.0 * Math.log(y);
          }
  
          eps = 1.0e-5;
          v = 0.0;
          s = 10.0;
          while (true) {
              v = v + 2;
  
              if (s <= eps) { break; }
              if ((qe = q_chi2(n, v) - y) === 0.0) { break; }
              if (qe < 0.0) {
                  v = v - s;
                  s = s / 10.0;
              }
          }
          return v;
      }
docs: [x, \infty) Pr([x, \infty)) = y -> x