Function calculates logarithm 2 of a kind of multinom.

    selectors: list of integers
335199
def multinomLog2(selectors):
    

    ln2 = 0.69314718055994528622
    noAll = sum(selectors)
    lgNf = math.lgamma(noAll + 1.0) / ln2  # log2(N!)

    lgnFac = []
    for selector in selectors:
        if selector == 0 or selector == 1:
            lgnFac.append(0.0)
        elif selector == 2:
            lgnFac.append(1.0)
        elif selector == noAll:
            lgnFac.append(lgNf)
        else:
            lgnFac.append(math.lgamma(selector + 1.0) / ln2)
    return lgNf - sum(lgnFac)
1263344
def nice_log(x):
    
    neg = x < 0
    xi = np.log2(np.abs(x) + 1)
    xi[neg] = -xi[neg]
    return xi
854041
def p_function_expr_2(self, p):
        
        if len(p) == 8:
            p[0] = self.asttypes.FuncExpr(
                identifier=p[2], parameters=None, elements=p[6])
        else:
            p[0] = self.asttypes.FuncExpr(
                identifier=p[2], parameters=p[4], elements=p[7])
        p[0].setpos(p)
441280
def _digits(minval, maxval):
    """"""
    if minval == maxval:
        return 3
    else:
        return min(10, max(2, int(1 + abs(np.log10(maxval - minval)))))
174270
def ks(self, num_ngrams):
        # type (int) -> [int]
        
        if self.num_bits:
            k = int(self.num_bits / num_ngrams)
            residue = self.num_bits % num_ngrams
            return ([k + 1] * residue) + ([k] * (num_ngrams - residue))
        else:
            return [self.k if self.k else 0] * num_ngrams
932902
function(a, el, sType, fn) {
                for (var i=0, l=a.length; i<l; i=i+1) {
                    var li = a[i];
                    if ( li                 && 
                         li[this.FN] == fn  && 
                         li[this.EL] == el  && 
                         li[this.TYPE] == sType ) {
                        return i;
                    }
                }

                return -1;
            }
91072
def num_trees(n):
    
    dp = [0] * (n+1)
    dp[0] = 1
    dp[1] = 1
    for i in range(2, n+1):
        for j in range(i+1):
            dp[i] += dp[i-j] * dp[j-1]
    return dp[-1]
93847
public static DoubleAD logSum(DoubleAD[] logInputs, int fromIndex, int toIndex) {
    if (logInputs.length == 0)
      throw new IllegalArgumentException();
    if(fromIndex >= 0 && toIndex < logInputs.length && fromIndex >= toIndex)
      return new DoubleAD(Double.NEGATIVE_INFINITY,Double.NEGATIVE_INFINITY);
    int maxIdx = fromIndex;
    double max = logInputs[fromIndex].getval();
    double maxdot = logInputs[fromIndex].getdot();

    for (int i = fromIndex+1; i < toIndex; i++) {
      if (logInputs[i].getval() > max) {
        maxIdx = i;
        maxdot = logInputs[i].getdot();
        max = logInputs[i].getval();
      }
    }

    DoubleAD ret = new DoubleAD();
    boolean haveTerms = false;
    double intermediate = 0.0;
    double intermediateDot = 0.0;
    double curEXP;
    double cutoff = max - SloppyMath.LOGTOLERANCE;
    // we avoid rearranging the array and so test indices each time!
    for (int i = fromIndex; i < toIndex; i++) {
      if (i != maxIdx && logInputs[i].getval() > cutoff) {
        haveTerms = true;
        curEXP = Math.exp(logInputs[i].getval() - max);
        intermediate += curEXP;
        intermediateDot += curEXP*logInputs[i].getdot();
      }
    }
    if (haveTerms) {
      ret.setval(max + Math.log(1.0 + intermediate));
      ret.setdot((maxdot + intermediateDot)/(1.0 + intermediate));
    } else {
      ret.setval(max);
      ret.setdot(maxdot);
    }
      return ret;
  }
640041
function(num) {
            if(typeof num !== "number") {
                return NaN;
            }
            var isNegative = num < 0;
            num = (isNegative) ? -num : num;
            var log = this.logBaseTen(num),
                result = Math.pow(10, Math.floor(log));

            return (isNegative) ? -result: result;
        }
579831
public static int simpleIntLog2(final int x) {
    final int exp = Integer.numberOfTrailingZeros(x);
    if (x != (1 << exp)) {
      throw new SketchesArgumentException("Argument x cannot be negative or zero.");
    }
    return exp;
  }
1014368
function nextPow2(size) {
  return Math.pow(2, Math.ceil(Math.log(size) / Math.LN2));
}
893760
def _lognl(self):
        
        try:
            return self.__lognl
        except AttributeError:
            det_lognls = {}
            for (det, d) in self._data.items():
                kmin = self._kmin
                kmax = self._kmax
                det_lognls[det] = -0.5 * d[kmin:kmax].inner(d[kmin:kmax]).real
            self.__det_lognls = det_lognls
            self.__lognl = sum(det_lognls.values())
            return self.__lognl
489683
def log_power(x, a, b, c):
    "
    return a/(1.+(x/np.exp(b))**c)
230957
def L(self, x, tau):
        

        return np.log(x * (tau + np.sqrt(tau ** 2 + x ** 2)) ** -1)
662502
def log2(x, context=None):
    
    return _apply_function_in_current_context(
        BigFloat,
        mpfr.mpfr_log2,
        (BigFloat._implicit_convert(x),),
        context,
    )
1345364
function(nodes, formula, root, reverse, ofType) {
      if (nodes.length == 0) return [];
      if (formula == 'even') formula = '2n+0';
      if (formula == 'odd')  formula = '2n+1';
      var h = Selector.handlers, results = [], indexed = [], m;
      h.mark(nodes);
      for (var i = 0, node; node = nodes[i]; i++) {
        if (!node.parentNode._counted) {
          h.index(node.parentNode, reverse, ofType);
          indexed.push(node.parentNode);
        }
      }
      if (formula.match(/^\d+$/)) { // just a number
        formula = Number(formula);
        for (var i = 0, node; node = nodes[i]; i++)
          if (node.nodeIndex == formula) results.push(node);
      } else if (m = formula.match(/^(-?\d*)?n(([+-])(\d+))?/)) { // an+b
        if (m[1] == "-") m[1] = -1;
        var a = m[1] ? Number(m[1]) : 1;
        var b = m[2] ? Number(m[2]) : 0;
        var indices = Selector.pseudos.getIndices(a, b, nodes.length);
        for (var i = 0, node, l = indices.length; node = nodes[i]; i++) {
          for (var j = 0; j < l; j++)
            if (node.nodeIndex == indices[j]) results.push(node);
        }
      }
      h.unmark(nodes);
      h.unmark(indexed);
      return results;
    }
1259142
function(x){
    return Math.pow(10, Math.floor(Math.log(x) / Math.LN10));
  }