Returns series of length k whose i-th entry is the precision in the top i
    TODO: extrapolate here
335218
def precision_series(y_true, y_score, k=None):
    
    y_true, y_score = to_float(y_true, y_score)
    top = _argsort(y_score, k)

    n = np.nan_to_num(y_true[top]).cumsum()  # fill missing labels with 0
    d = (~np.isnan(y_true[top])).cumsum()    # count number of labels
    return pd.Series(n/d, index=np.arange(1, len(n)+1))
209281
public int precision() {
        int result = precision;
        if (result == 0) {
            long s = intCompact;
            if (s != INFLATED)
                result = longDigitLength(s);
            else
                result = bigDigitLength(intVal);
            precision = result;
        }
        return result;
    }
1021325
def _pos(self, k):
        
        if k < 2:
            raise ValueError("k smaller than 2")
        G = np.zeros((self.m, self.m))
        for i in range(self.m):
            for j in range(self.m):
                if i == j:
                    continue
                if i < k or j < k:
                    continue
                if i == k or j == k:
                    G[i][j] = 1
        return G
246499
public static int getKFromEpsilon(final double epsilon, final boolean pmf) {
    //Ensure that eps is >= than the lowest possible eps given MAX_K and pmf=false.
    final double eps = max(epsilon, 4.7634E-5);
    final double kdbl = pmf
        ? exp(log(2.446 / eps) / 0.9433)
        : exp(log(2.296 / eps) / 0.9723);
    final double krnd = round(kdbl);
    final double del = abs(krnd - kdbl);
    final int k = (int) ((del < 1E-6) ? krnd : ceil(kdbl));
    return max(MIN_K, min(MAX_K, k));
  }
741590
def Kdiag(self, X):
        """"""
        K_ff = np.ones(X.shape[0])
        for i,x in enumerate(X):
            for il,l in enumerate(self.lengthscale):
                idx = il*2
                K_ff[i] *= self.k_ff(x[idx],x[idx],l)
        return K_ff * self.variances[0]
1263450
function $$core$$ToRawPrecision (x, minPrecision, maxPrecision) {
        var
        // 1. Let p be maxPrecision.
            p = maxPrecision;

        // 2. If x = 0, then
        if (x === 0) {
            var
            // a. Let m be the String consisting of p occurrences of the character "0".
                m = $$core$$arrJoin.call(Array (p + 1), '0'),
            // b. Let e be 0.
                e = 0;
        }
        // 3. Else
        else {
            // a. Let e and n be integers such that 10ᵖ⁻¹ ≤ n < 10ᵖ and for which the
            //    exact mathematical value of n × 10ᵉ⁻ᵖ⁺¹ – x is as close to zero as
            //    possible. If there are two such sets of e and n, pick the e and n for
            //    which n × 10ᵉ⁻ᵖ⁺¹ is larger.
            var
                e = $$core$$log10Floor(Math.abs(x)),

                // Easier to get to m from here
                f = Math.round(Math.exp((Math.abs(e - p + 1)) * Math.LN10)),

            // b. Let m be the String consisting of the digits of the decimal
            //    representation of n (in order, with no leading zeroes)
                m = String(Math.round(e - p + 1 < 0 ? x * f : x / f));
        }

        // 4. If e ≥ p, then
        if (e >= p)
            // a. Return the concatenation of m and e-p+1 occurrences of the character "0".
            return m + $$core$$arrJoin.call(Array(e-p+1 + 1), '0');

        // 5. If e = p-1, then
        else if (e === p - 1)
            // a. Return m.
            return m;

        // 6. If e ≥ 0, then
        else if (e >= 0)
            // a. Let m be the concatenation of the first e+1 characters of m, the character
            //    ".", and the remaining p–(e+1) characters of m.
            m = m.slice(0, e + 1) + '.' + m.slice(e + 1);

        // 7. If e < 0, then
        else if (e < 0)
            // a. Let m be the concatenation of the String "0.", –(e+1) occurrences of the
            //    character "0", and the string m.
            m = '0.' + $$core$$arrJoin.call(Array (-(e+1) + 1), '0') + m;

        // 8. If m contains the character ".", and maxPrecision > minPrecision, then
        if (m.indexOf(".") >= 0 && maxPrecision > minPrecision) {
            var
            // a. Let cut be maxPrecision – minPrecision.
                cut = maxPrecision - minPrecision;

            // b. Repeat while cut > 0 and the last character of m is "0":
            while (cut > 0 && m.charAt(m.length-1) === '0') {
                //  i. Remove the last character from m.
                m = m.slice(0, -1);

                //  ii. Decrease cut by 1.
                cut--;
            }

            // c. If the last character of m is ".", then
            if (m.charAt(m.length-1) === '.')
                //    i. Remove the last character from m.
                m = m.slice(0, -1);
        }
        // 9. Return m.
        return m;
    }
1257276
public static long binCoeff(int n, int k) {
                if (k > n) {
                        return 0;
                }
                if (k == 0 || k == n) {
                        return 1;
                }
                long result = 1;
                for (int i = 1; i <= k; i++) {
                        result *= (n - i + 1) / i;
                }
                return result;
        }
95471
def kth_smallest(self, root, k):
        
        count = []
        self.helper(root, count)
        return count[k-1]
841538
function(x) {
    return this.map(function(p) {
      return (Math.abs(p - x) <= Sylvester.precision) ? x : p;
    });
  }
949605
function(x) {
    return this.map(function(y) {
      return (Math.abs(y - x) <= Sylvester.precision) ? x : y;
    });
  }
1207910
def k_bn(self, n, Re):
        
        bn = self.b_n(n)
        k = bn*Re**(-1./n)
        return k, bn
622883
def precision(self):
        
        true_pos = self.matrix[0][0]
        false_pos = self.matrix[1][0]
        return divide(1.0 * true_pos, true_pos + false_pos)
840469
private static int calcAdjustedMinimumSequenceLength(
			List<Subunit> subunits, int absMinLen, double fraction, int minLen) {

		int maxLength = Integer.MIN_VALUE;
		int minLength = Integer.MAX_VALUE;

		// Extract the length List, the min and the max
		List<Integer> lengths = new ArrayList<Integer>();
		for (int i = 0; i < subunits.size(); i++) {
			if (subunits.get(i).size() >= absMinLen) {
				maxLength = Math.max(subunits.get(i).size(), maxLength);
				minLength = Math.min(subunits.get(i).size(), minLength);
				lengths.add(subunits.get(i).size());

			}
		}

		int adjustedMinimumSequenceLength = minLen;

		if (lengths.size() < 2)
			return adjustedMinimumSequenceLength;

		// Calculate the median of the lengths
		double median = 0;
		Collections.sort(lengths);
		if (lengths.size() % 2 == 1) {
			int middle = (lengths.size() - 1) / 2;
			median = lengths.get(middle);
		} else {
			int middle2 = lengths.size() / 2;
			int middle1 = middle2 - 1;
			median = 0.5 * (lengths.get(middle1) + lengths.get(middle2));
		}

		// If the median * fraction is lower than the minLength
		if (minLength >= median * fraction) {
			adjustedMinimumSequenceLength = Math.min(minLength, minLen);
		}

		return adjustedMinimumSequenceLength;
	}
1302569
def Max(self, k):
        
        cdf = self.MakeCdf()
        cdf.ps = [p ** k for p in cdf.ps]
        return cdf
1012040
def choose(n, k):
    
    if 0 <= k <= n:
        ntok = 1
        ktok = 1
        for t in xrange(1, min(k, n - k) + 1):
            ntok *= n
            ktok *= t
            n -= 1
        return ntok // ktok
    else:
        return 0
318222
private void ins(int k)
	{

		//if(last > 0)    last = sapp[-1] += k;
		//else            last = *sapp++ = (k);
		if(last > 0)    last = sapp[sappPos-1]   +=  k;
		else            last = sapp[(sappPos++)]  = (k);
	}
664480
def determine_lengths(dtrajs):
    
    """
    if (isinstance(dtrajs[0], (int))):
        return len(dtrajs) * np.ones((1))
    lengths = np.zeros((len(dtrajs)))
    for i in range(len(dtrajs)):
        lengths[i] = len(dtrajs[i])
    return lengths