Accumulation/Distribution.

    Formula:
    A/D = (Ct - Lt) - (Ht - Ct) / (Ht - Lt) * Vt + A/Dt-1
326859
def accumulation_distribution(close_data, high_data, low_data, volume):
    
    catch_errors.check_for_input_len_diff(
        close_data, high_data, low_data, volume
        )

    ad = np.zeros(len(close_data))
    for idx in range(1, len(close_data)):
        ad[idx] = (
            (((close_data[idx] - low_data[idx]) -
                (high_data[idx] - close_data[idx])) /
                (high_data[idx] - low_data[idx]) *
                volume[idx]) +
            ad[idx-1]
            )
    return ad
973279
def dKdiag_dtheta(self, dL_dKdiag, X, target):
        """"""
        target += 2.*self.mapping.df_dtheta(dL_dKdiag[:, None]*self.mapping.f(X), X)
61662
def _dM(self, k, t, param, M, tips=None, gaps=None):
        """"""
        if self._distributionmodel:
            return self.model.dM(k, t, param, M, tips, gaps)
        else:
            return self.model.dM(t, param, M, tips, gaps)
757464
def utime_delta(days=0, hours=0, minutes=0, seconds=0):
    
    return (days * DAY) + (hours * HOUR) + (minutes * MINUTE) + (seconds * SECOND)
503175
function je(ct,pt,ut,bt){var kt=ct.indexOf("."),It=Ye,At=We,ht,mt,yt,_t,vt,xt,St;// Remove trailing zeros.
for(37>ut&&(ct=ct.toLowerCase()),0<=kt&&(yt=st,st=0,ct=ct.replace(".",""),St=new Ne(ut),vt=St.pow(ct.length-kt),st=yt,St.c=ue(he(ce(vt.c),vt.e),10,pt),St.e=St.c.length),xt=ue(ct,ut,pt),mt=yt=xt.length;0==xt[--yt];xt.pop());if(!xt[0])return"0";if(0>kt?--mt:(vt.c=xt,vt.e=mt,vt.s=bt,vt=He(vt,St,It,At,pt),xt=vt.c,_t=vt.r,mt=vt.e),ht=mt+It+1,kt=xt[ht],yt=pt/2,_t=_t||0>ht||null!=xt[ht+1],_t=4>At?(null!=kt||_t)&&(0==At||At==(0>vt.s?3:2)):kt>yt||kt==yt&&(4==At||_t||6==At&&1&xt[ht-1]||At==(0>vt.s?8:7)),1>ht||!xt[0])ct=_t?he("1",-It):"0";else{if(xt.length=ht,_t)// Rounding up may mean the previous digit has to be rounded up and so on.
for(--pt;++xt[--ht]>pt;)xt[ht]=0,ht||(++mt,xt=[1].concat(xt));// Determine trailing zeros.
for(yt=xt.length;!xt[--yt];);// E.g. [4, 11, 15] becomes 4bf.
for(kt=0,ct="";kt<=yt;ct+=we.charAt(xt[kt++]));ct=he(ct,mt)}// The caller will add the sign.
return ct}
1139191
public static double cdf(double val, double loc, double scale, double shape1, double shape2) {
    val = (val - loc) / scale;
    if(val == Double.NEGATIVE_INFINITY) {
      return 0.;
    }
    if(val == Double.POSITIVE_INFINITY) {
      return 1.;
    }
    if(val != val) {
      return Double.NaN;
    }
    if(shape1 == 0.) {
      val = FastMath.exp(-val);
    }
    else {
      double tmp = shape1 * val;
      if(tmp == Double.NEGATIVE_INFINITY) {
        return shape2 == 0 ? 1 : 0.;
      }
      if(tmp >= 1.) {
        return shape2 == 0 ? 0 : 1.;
      }
      val = FastMath.exp(FastMath.log1p(-tmp) / shape1);
    }
    if(shape2 == 0.) {
      return FastMath.exp(-val);
    }
    final double tmp = shape2 * val;
    return tmp < 1. ? FastMath.exp(FastMath.log1p(-tmp) / shape2) : 0.;
  }
707982
def F_t(X, Y, S, M_E, E, m0, rho):
    '''  '''
    r = X.shape[1]
    out1 = (((np.dot(np.dot(X, S), Y.T) - M_E) * E)**2).sum() / 2
    out2 = rho * G(Y, m0, r)
    out3 = rho * G(X, m0, r)

    return out1 + out2 + out3
763259
def cal_pst(self, v):
        
        p_h = self._hugoniot_p(v)
        p_th_h = self._hugoniot_pth(v)
        p_st = p_h - p_th_h
        return p_st
1310267
def _calcOnAxisFactor(self, aLocation, deltaAxis, deltasOnSameAxis, deltaLocation):
        
        if deltaAxis == "origin":
            f = 0
            v = 0
        else:
            f = aLocation[deltaAxis]
            v = deltaLocation[deltaAxis]
        i = []
        iv = {}
        for value in deltasOnSameAxis:
            iv[Location(value)[deltaAxis]]=1
        i = sorted(iv.keys())
        r = 0
        B, M, A = [], [], []
        mA, mB, mM = None, None, None
        for value in i:
            if value < f: B.append(value)
            elif value > f: A.append(value)
            else: M.append(value)
        if len(B) > 0:
            mB = max(B)
            B.sort()
        if len(A) > 0:
            mA = min(A)
            A.sort()
        if len(M) > 0:
            mM = min(M)
            M.sort()
        if mM is not None:
            if ((f-_EPSILON <  v) and (f+_EPSILON > v)) or f==v: r = 1
            else: r = 0
        elif mB is not None and mA is not None:
            if v < mB or v > mA: r = 0
            else:
                if v == mA:
                    r = float(f-mB)/(mA-mB)
                else:
                    r = float(f-mA)/(mB-mA)
        elif mB is None and mA is not None:
            if v==A[1]:
                r = float(f-A[0])/(A[1]-A[0])
            elif v == A[0]:
                r = float(f-A[1])/(A[0]-A[1])
            else:
                r = 0
        elif  mB is not None and mA is None:
            if v == B[-2]:
                r = float(f-B[-1])/(B[-2]-B[-1])
            elif v == mB:
                r = float(f-B[-2])/(B[-1]-B[-2])
            else:
                r = 0
        return r
1150046
function dtlog(df) {
      var t;

      t = -bd0(df / 2, (df + 1) / 2) + stirlerr((df + 1) / 2) - stirlerr(df / 2);
      return function(x) {
         var x2n, logx2n, u;

         if (utils.hasNaN(x, df) || df <= 0) { return NaN; }

         x2n = x * x / df;
         logx2n = Math.log(1 + x2n) / 2;
         u = x2n > 0.2 ? df * logx2n
                       : x * x / 2 - bd0(df / 2, (df + x * x) / 2);
         return t - u - (logx2n + Math.log(sqrt2pi));
      };
   }
788953
def _get_charge_distribution_df(self):
        
        # Fraction coordinates and corresponding indices
        axis_grid = np.array([np.array(self.chgcar.get_axis_grid(i)) /
                              self.structure.lattice.abc[i] for i in range(3)])
        axis_index = np.array([range(len(axis_grid[i])) for i in range(3)])

        data = {}

        for index in itertools.product(*axis_index):
            a, b, c = index
            f_coords = (axis_grid[0][a], axis_grid[1][b], axis_grid[2][c])
            data[f_coords] = self.chgcar.data["total"][a][b][c]

        # Fraction coordinates - charge density table
        df = pd.Series(data).reset_index()
        df.columns = ['a', 'b', 'c', 'Charge Density']
        self._charge_distribution_df = df

        return df
354810
def nb_r_deriv(r, data_row):
    
    n = len(data_row)
    d = sum(digamma(data_row + r)) - n*digamma(r) + n*np.log(r/(r+np.mean(data_row)))
    return d
1153747
def Itaax(mt, x, t):
    
    return (Sx(mt, x) - Sx(mt, x + t)) / Dx(mt, x)
47996
def deriv(f,c,dx=0.0001):
    
    return (f(c+dx)-f(c-dx))/(2*dx)
694660
def _get_um_dm(cls, df):
        
        hd = df['high_delta']
        df['um'] = (hd + hd.abs()) / 2
        ld = -df['low_delta']
        df['dm'] = (ld + ld.abs()) / 2
763014
def Kdiag(self, X):
        """"""
        ret = np.empty(X.shape[0])
        ret[:] = self.variance
        return ret
557182
def accumulate(self, buf):
        ''''''
        bytes = array.array('B')
        if isinstance(buf, array.array):
            bytes.extend(buf)
        else:
            bytes.fromstring(buf)
        accum = self.crc
        for b in bytes:
            tmp = b ^ (accum & 0xff)
            tmp = (tmp ^ (tmp<<4)) & 0xFF
            accum = (accum>>8) ^ (tmp<<8) ^ (tmp<<3) ^ (tmp>>4)
            accum = accum & 0xFFFF
        self.crc = accum