Helper function to compute the inflation/deflation based on a value and
        a reference value
188055
def _compute_inflation(value, reference_value):
        
        res = value / float(reference_value)
        return InflationResult(factor=res, value=res - 1)
599086
def function(x, ax, ay):
    '''
    
    '''
    with np.errstate(invalid='ignore'):
        return ay * (x - ax)**0.5
493935
function by(val, start, m, r, i) {
    return (m = relVal.exec(val)) ?
      (i = parseFloat(m[2])) && (start + (m[1] == '+' ? 1 : -1) * i) :
      parseFloat(val)
  }
1236915
def money_flow(close_data, high_data, low_data, volume):
    
    catch_errors.check_for_input_len_diff(
        close_data, high_data, low_data, volume
        )
    mf = volume * tp(close_data, high_data, low_data)
    return mf
921471
def stress(ref_cds, est_cds):
    
    ref_dists = pdist(ref_cds)
    est_dists = pdist(est_cds)
    return np.sqrt(((ref_dists - est_dists)**2).sum() / (ref_dists**2).sum())
982399
private int calcTZeroDepth(int proposedK)
    {
        int d = -1;
        if ( (proposedK >= 0) && (proposedK < _t0_d.length) )
            d = _t0_d[proposedK];
        if (d < 0)
        {
            String x =
            "K Factor (" + proposedK + ") is invalid.\n" +
            "Valid K factors are: " + kFactorString() + ".";
            throw new IllegalArgumentException(x);
        }
        return d;
    }
1100116
def reduce_fn(x):
    
    values = x.values if pd and isinstance(x, pd.Series) else x
    for v in values:
        if not is_nan(v):
            return v
    return np.NaN
855590
def _bisect_interval(a, b, fa, fb):
    """"""
    if fa*fb > 0:
        raise ValueError("f(a) and f(b) must have different signs")
    root = 0.0
    status = _ECONVERR

    # Root found at either end of [a,b]
    if fa == 0:
        root = a
        status = _ECONVERGED
    if fb == 0:
        root = b
        status = _ECONVERGED

    return root, status
1296150
def calculate_rates(base_currency, counter_currency, forward_rate=None, fwd_points=None, spot_reference=None):
    """"""
    if base_currency not in DIVISOR_TABLE:
        divisor = DIVISOR_TABLE.get(counter_currency, DEFAULT_DIVISOR)
        if forward_rate is None and fwd_points is not None and spot_reference is not None:
            forward_rate = spot_reference + fwd_points / divisor
        elif forward_rate is not None and fwd_points is None and spot_reference is not None:
            fwd_points = (forward_rate - spot_reference) * divisor
        elif forward_rate is not None and fwd_points is not None and spot_reference is None:
            spot_reference = forward_rate - fwd_points / divisor

    rates = {}
    if forward_rate is not None:
        rates['forward_rate'] = forward_rate

    if fwd_points is not None:
        rates['fwd_points'] = fwd_points

    if spot_reference is not None:
        rates['spot_reference'] = spot_reference

    return rates
340468
def spread_money(money: Money, spread_p: Decimal) -> Tuple[Money, Money]:
    """"""
    upper, lower = spread_value(money.amount, spread_p)
    return Money(upper, money.currency), Money(lower, money.currency)
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
2754
def ACC_calc(TP, TN, FP, FN):
    
    try:
        result = (TP + TN) / (TP + TN + FN + FP)
        return result
    except ZeroDivisionError:
        return "None"
489900
def takef(d,l,val=None):
    ''''''
    return {i:(d[i] if i in d else val)
            for i in l};
1372855
def compute_discounts(self, precision=None):
        '''
        
        '''
        return sum([line.compute_discounts(precision) for line in self.__lines])
138555
def F_calc(TP, FP, FN, beta):
    
    try:
        result = ((1 + (beta)**2) * TP) / \
            ((1 + (beta)**2) * TP + FP + (beta**2) * FN)
        return result
    except ZeroDivisionError:
        return "None"
915806
function calculateMaxValue(precision, scale) {
  const arr = _.fill(Array(precision), '9');

  if (scale) {
    arr.splice(precision - scale, 0, '.');
  }

  return parseFloat(arr.join(''));
}
1052097
function p_t(df, t) {
        var c2, s, p, i;

        c2 = df / (df + t * t);
        s = Math.sqrt(1.0 - c2);

        if (t < 0.0) { s = -s; }

        p = 0.0;
        i = df % 2 + 2;
        while (i <= df) {
            p = p + s;
            s = s * ((i - 1) * c2 / i);
            i = i + 2;
        }

        if ((df & 1) !== 0) {
            return 0.5 + (p * Math.sqrt(c2) + Math.atan(t / Math.sqrt(df))) / Math.PI;
        }

        return (1.0 + p) / 2.0;
    }