docs: function qbeta(a, b, lowerTail, logp) {
        var f;
  
        lowerTail = lowerTail !== false;
        logp = logp === true;
        f = pbeta(a, b, lowerTail, logp);
  
        if (utils.hasNaN(a, b) || a < 0 || b < 0) {
           return function() { return NaN; };
        }
  
        /* eslint-disable complexity */
        return utils.qhelper(lowerTail, logp, 0, 1, function(p) {
           // need reasonable endpoints
           var l, u, incr, unloggedp;
  
           if (utils.hasNaN(p)) { return NaN; }
  
           unloggedp = logp ? Math.exp(p) : p;
  
           if (a === 0 && b === 0) { // point mass 1/2 at each of {0,1}
              // WARNING: Following R here, and ignoring the question of
              // upper/lower tail.
              return unloggedp < 0.5 ? 0
                   : unloggedp > 0.5 ? 1
                   : 0.5;
           }
           if (a === Infinity && b === Infinity) { // point mass 1 at 1/2
              return 0.5;
           }
           if (a / b === 0) { // point mass 1 at 0 ==> P(X <= x) = 1, all x > 0
              return 0;
           }
           if (b / a === 0) { // point mass 1 at 1 ==> P(X <= x) = 0, all x < 1
              return 1;
           }
  
           incr = 1e-1;
           l = 1e-1;
           while (f(l) > p === lowerTail) {
              l *= incr;
              if (l < 1e-80) {
                 return new Error('qbeta failed to find left endpoint');
              }
           }
           u = 1 - incr;
           while (f(u) < p === lowerTail) {
              incr *= 0.1;
              u = 1 - incr;
              if (incr < 1e-80) {
                 return new Error('qbeta failed to find right endpoint');
              }
           }
           /* eslint-enable complexity */
  
           return solve(function(x) { return f(x); }, p, l, u);
        });
     }