http://en.wikipedia.org/wiki/Average_true_range
    The greatest of the following:
    - Current High less the current Low
    - Current High less the previous Close (absolute value)
    - Curre    nt Low less the previous Close (absolute value)
763211
def true_range(arg, high_col='high', low_col='low', close_col='close', skipna=0):
    
    _ensure_col(arg, high_col=high_col, low_col=low_col, close_col=close_col)
    yclose = arg[close_col].shift(1)
    low, high = arg[low_col], arg[high_col]
    mx = pd.DataFrame({'a': high, 'b': yclose}).max(axis=1, skipna=skipna)
    mn = pd.DataFrame({'a': low, 'b': yclose}).min(axis=1, skipna=skipna)
    result = mx - mn
    return pd.Series(result, index=arg.index, name='true_range')
915122
def average_precision(truth, recommend):
    
    if len(truth) == 0:
        if len(recommend) == 0:
            return 1.
        return 0.

    tp = accum = 0.
    for n in range(recommend.size):
        if recommend[n] in truth:
            tp += 1.
            accum += (tp / (n + 1.))
    return accum / truth.size
1108467
def get_range(self):
        """"""
        (min, max) = (100000, -1)
        for cont in self.bar:
            for note in cont[2]:
                if int(note) < int(min):
                    min = note
                elif int(note) > int(max):
                    max = note
        return (min, max)
773042
def average_returns(ts, **kwargs):
    ''' '''
    average_type = kwargs.get('type', 'net')
    if average_type == 'net':
        relative = 0
    else:
        relative = -1  # gross
    #start = kwargs.get('start', ts.index[0])
    #end = kwargs.get('end', ts.index[len(ts.index) - 1])
    #delta = kwargs.get('delta', ts.index[1] - ts.index[0])
    period = kwargs.get('period', None)
    if isinstance(period, int):
        pass
    #else:
        #ts = reIndexDF(ts, start=start, end=end, delta=delta)
        #period = 1
    avg_ret = 1
    for idx in range(len(ts.index)):
        if idx % period == 0:
            avg_ret *= (1 + ts[idx] + relative)
    return avg_ret - 1
786542
def average(old_avg, current_value, count):
    
    if old_avg is None:
        return current_value
    return (float(old_avg) * count + current_value) / (count + 1)
217183
def selection_range(self):  # XXX: shouldn't this return `None` if there is no selection???
        
        if self.selection:
            from_, to = sorted([self.cursor_position, self.selection.original_cursor_position])
        else:
            from_, to = self.cursor_position, self.cursor_position

        return from_, to
338196
def selection_range(self):
        
        selected = self.selectionModel().selection()
        """:type: QItemSelection """

        if selected.isEmpty():
            return -1, -1

        min_row = min(rng.top() for rng in selected)
        max_row = max(rng.bottom() for rng in selected)

        return min_row, max_row
666627
def range_per(self):
    
    rp = float((self.raw_data[-1] - self.raw_data[-2]) / self.raw_data[-2] * 100)
    return rp
1118864
def maxDepth(self, currentDepth=0):
        """"""
        if not any((self.left, self.right)):
            return currentDepth
        result = 0
        for child in (self.left, self.right):
            if child:
                result = max(result, child.maxDepth(currentDepth + 1))
        return result
907141
def maxdiff(self):
        
        POW  = math.pow
        D = 0
        for i in range(self.width):
            _min = 100
            _max = -100
            for L in ACGT:
                val = POW(2,self.logP[i][L])
                if   val > _max:
                    _max  = val
                    _maxL = L
                elif val < _min:
                    _min  = val
                    _minL = L
            for L in ACGT:
                if L == _minL:
                    delta = 1-POW(2,self.logP[i][L])           #1-val
                    D = D + delta*delta
                else:
                    D = D + POW( POW(2,self.logP[i][L]), 2)    #0-val
        return(math.sqrt(D))
861633
def price_range(self):
        
        ordered = self.variants.order_by('base_price')
        if ordered:
            return ordered.first().price, ordered.last().price
        else:
            return None, None
1316684
def abs_thresholds(scale, max_value)
      at = []
      scale.each { |v|
        at.push(v * max_value)
      }
      return at
    end
694151
def average_true_range_percent(close_data, period):
    
    catch_errors.check_for_period_error(close_data, period)
    atrp = (atr(close_data, period) / np.array(close_data)) * 100
    return atrp
1351138
def search_greater(values, target):
    
    first = 0
    last = len(values)

    while first < last:
        middle = (first + last) // 2
        if values[middle][0] < target:
            first = middle + 1
        else:
            last = middle

    return first
1272942
public void calcAutoScale() {
        double maxNoOfMajorTicks = 10;
        double maxNoOfMinorTicks = 10;
        double minValue          = getMinValue();
        double maxValue          = getMaxValue();
        double range             = maxValue - minValue;
        double niceRange         = (Helper.calcNiceNumber(range, false));
        setMajorTickSpace(Helper.calcNiceNumber(niceRange / (maxNoOfMajorTicks - 1), true));
        double niceMinValue      = (Math.floor(minValue / getMajorTickSpace()) * getMajorTickSpace());
        double niceMaxValue      = (Math.ceil(maxValue / getMajorTickSpace()) * getMajorTickSpace());
        setMinorTickSpace(Helper.calcNiceNumber(getMajorTickSpace() / (maxNoOfMinorTicks - 1), true));
        setMinValue(niceMinValue);
        setMaxValue(niceMaxValue);
    }
118993
def range_end(self):
        '''
        '''
        count = self.count
        range_end = self.range_start + self.limit - 1
        if count < range_end:
            range_end = count
        return range_end
437649
def selection_range
      from = [@text_input.selection_start, caret_position].min
      to = [@text_input.selection_start, caret_position].max

      (from...to)
    end