Calculate delta_kt_prime (Perez eqn 2 and eqn 3), or return a default value
    for use with :py:func:`_dirint_bins`.
345382
def _delta_kt_prime_dirint(kt_prime, use_delta_kt_prime, times):
    
    if use_delta_kt_prime:
        # Perez eqn 2
        kt_next = kt_prime.shift(-1)
        kt_previous = kt_prime.shift(1)
        # replace nan with values that implement Perez Eq 3 for first and last
        # positions. Use kt_previous and kt_next to handle series of length 1
        kt_next.iloc[-1] = kt_previous.iloc[-1]
        kt_previous.iloc[0] = kt_next.iloc[0]
        delta_kt_prime = 0.5 * ((kt_prime - kt_next).abs().add(
                                (kt_prime - kt_previous).abs(),
                                fill_value=0))
    else:
        # do not change unless also modifying _dirint_bins
        delta_kt_prime = pd.Series(-1, index=times)
    return delta_kt_prime
79347
def K(self):
        """"""
        K1 = np.float_power(pi, 0.5 * self.n_min * self.n_min)
        K1 /= (
            np.float_power(2, 0.5 * self.n_min * self._n_max)
            * self._mgamma(0.5 * self._n_max, self.n_min)
            * self._mgamma(0.5 * self.n_min, self.n_min)
        )

        K2 = np.float_power(
            2, self.alpha * self.size + 0.5 * self.size * (self.size + 1)
        )
        for i in xrange(self.size):
            K2 *= gamma(self.alpha + i + 1)
        return K1 * K2
843157
def subtract_and_get(self, delta):
        '''
        
        '''
        with self._lock.exclusive:
            self._value -= delta
            return self._value
384947
function calcProp(ka, p) {
  var val = ka[p];
  if (isKeepAssigned(val)) {
    recalc(val);
  } else {
    val.val = findFirstProp(ka.objs, p);
  }
}
382276
def kld(p1, p2):
    
    return np.sum(np.where(p1 != 0, p1 * np.log(p1 / p2), 0))
22497
def do_int(value, default=0):
    
    try:
        return int(value)
    except (TypeError, ValueError):
        # this quirk is necessary so that "42.23"|int gives 42.
        try:
            return int(float(value))
        except (TypeError, ValueError):
            return default
81036
def F(self, **kwargs):
        '''
        
        '''
        Eg = self.Eg_Gamma_0(**kwargs)
        Delta_SO = self.Delta_SO(**kwargs)
        Ep = self.Ep(**kwargs)
        meff = self.meff_e_Gamma_0(**kwargs)
        return (1./meff-1-(Ep*(Eg+2.*Delta_SO/3.))/(Eg*(Eg+Delta_SO)))/2
346347
def select_delta(dist_post_update, current_iteration,
                 clip_max, clip_min, d, theta, constraint):
  
  if current_iteration == 1:
    delta = 0.1 * (clip_max - clip_min)
  else:
    if constraint == 'l2':
      delta = np.sqrt(d) * theta * dist_post_update
    elif constraint == 'linf':
      delta = d * theta * dist_post_update

  return delta
1292264
public boolean eq(IntDoubleSortedVector other, double delta) {
        // This is slow, but correct.
        IntDoubleSortedVector v1 = IntDoubleSortedVector.getWithNoZeroValues(this, delta);
        IntDoubleSortedVector v2 = IntDoubleSortedVector.getWithNoZeroValues(other, delta);
                
        if (v2.size() != v1.size()) {
            return false;
        }

        for (IntDoubleEntry ve : v1) {
            if (!Primitives.equals(ve.get(), v2.get(ve.index()), delta)) {
                return false;
            }
        }
        for (IntDoubleEntry ve : v2) {
            if (!Primitives.equals(ve.get(), v1.get(ve.index()), delta)) {
                return false;
            }
        }
        return true;
    }
868044
def cal_p_bm3(v, k, p_ref=0.0):
    
    vvr = v / k[0]
    p = (p_ref - 0.5 * (3. * k[1] - 5. * p_ref) * (1. - vvr**(-2. / 3.)) +
         9. / 8. * k[1] * (k[2] - 4. + 35. / 9. * p_ref / k[1]) *
         (1. - vvr**(-2. / 3.))**2.) * vvr**(-5. / 3.)
    return p
1206682
def delta(n, d=None, center=0):
    
    if isinstance(n, six.integer_types):
        n = [n]
    if d is None:
        n0 = _np.asanyarray(n, dtype=_np.int32)
    else:
        n0 = _np.array(n * d, dtype=_np.int32)
    d = n0.size

    if center < 0:
        cind = [0] * d
    else:
        cind = []
        for i in xrange(d):
            cind.append(center % n0[i])
            center //= n0[i]
        if center > 0:
            cind = [0] * d
    cr = []
    for i in xrange(d):
        cur_core = _np.zeros((1, n0[i], 1))
        cur_core[0, cind[i], 0] = 1
        cr.append(cur_core)
    return _vector.vector.from_list(cr)
1035052
def _npdelta(self, a, delta):
        """"""
        for x in np.nditer(a, op_flags=["readwrite"]):
            delta += x
            x[...] = delta
        return a
1101441
def klm(p, q):
    """"""
    p, q = flatten(p), flatten(q)
    return max(abs(p * np.nan_to_num(np.log(p / q))))
47410
def factor_kkt(U_S, R, d):
    
    nineq = R.size(0)
    U_S[-nineq:, -nineq:] = torch.potrf(R + torch.diag(1 / d.cpu()).type_as(d))
995101
def tdist_ci(x, df, stderr, level):
    
    q = (1 + level)/2
    delta = stats.t.ppf(q, df) * stderr
    return x - delta, x + delta
1099573
def dp_from_ps(bk, pk, ps, pfull_coord):
    """"""
    return d_deta_from_phalf(phalf_from_ps(bk, pk, ps), pfull_coord)
787800
def tokprob(self, tok, nonT):
        

        p = self._T.get(tok, 0) / float(self._T.get(nonT, 1))
        if not p:
            p = MIN_PROB
        return p