code: function ptsub(q, n) {
          var eps;
  
          if (n === 1 && q > 0.001 && q < 0.01) {
              eps = 1.0e-4;
          } else if (n === 2 && q < 0.0001) {
              eps = 1.0e-4;
          } else if (n === 1 && q < 0.001) {
              eps = 1.0e-2;
          } else {
              eps = 1.0e-5;
          }
  
          s = 10000.0;
          w = 0.0;
          while (true) {
              w = w + s;
  
              if (s <= eps) { return w; }
              if ((qe = 2.0 - p_t(n, w) * 2.0 - q) === 0.0) { return w; }
              if (qe < 0.0) {
                  w = w - s;
                  s = s / 10.0;
              }
          }
      }
docs: inverse of t-distribution ([2]) (-\infty, -q/2] + [q/2, \infty)