This calculated the average value of the time series over the given
        time range from `start` to `end`, when `mask` is truthy.
6844
def mean(self, start=None, end=None, mask=None):
        
        return self.distribution(start=start, end=end, mask=mask).mean()
524576
def average():
    
    count = 0
    total = total()
    i=0
    while 1:
        i = yield ((total.send(i)*1.0)/count if count else 0)
        count += 1
781149
private void calculate(String mask) {
        Matcher matcher = cidrPattern.matcher(mask);

        if (matcher.matches()) {
            address = matchAddress(matcher);

            /* Create a binary netmask from the number of bits specification /x */
            int cidrPart = rangeCheck(Integer.parseInt(matcher.group(5)), 0, NBITS);
            for (int j = 0; j < cidrPart; ++j) {
                netmask |= (1 << 31 - j);
            }

        } else {
            throw new IllegalArgumentException("Could not parse [" + mask + "]");
        }
    }
1193188
def linear_weighted_moving_average(data, period):
    
    catch_errors.check_for_period_error(data, period)

    idx_period = list(range(1, period+1))
    lwma = [(sum([i * idx_period[data[idx-(period-1):idx+1].index(i)]
              for i in data[idx-(period-1):idx+1]])) /
            sum(range(1, len(data[idx+1-period:idx+1])+1)) for idx in range(period-1, len(data))]
    lwma = fill_for_noncomputable_vals(data, lwma)
    return lwma
254073
def moving_average_convergence(data, nslow=26, nfast=12):
    
    emaslow = moving_average(data, nslow, type='exponential')
    emafast = moving_average(data, nfast, type='exponential')
    return emaslow, emafast, emafast - emaslow
93092
def mavg(data, xseq, **params):
    
    window = params['method_args']['window']

    # The first average comes after the full window size
    # has been swept over
    rolling = data['y'].rolling(**params['method_args'])
    y = rolling.mean()[window:]
    n = len(data)
    stderr = rolling.std()[window:]
    x = data['x'][window:]
    data = pd.DataFrame({'x': x, 'y': y})
    data.reset_index(inplace=True, drop=True)

    if params['se']:
        df = n - window  # Original - Used
        data['ymin'], data['ymax'] = tdist_ci(
            y, df, stderr, params['level'])
        data['se'] = stderr

    return data
734938
def _ValidateClosedTimeRange(time_range):
  """"""
  time_range_start, time_range_end = time_range
  _ValidateTimestamp(time_range_start)
  _ValidateTimestamp(time_range_end)
  if time_range_start > time_range_end:
    raise ValueError("Invalid time-range: %d > %d." %
                     (time_range_start.AsMicrosecondsSinceEpoch(),
                      time_range_end.AsMicrosecondsSinceEpoch()))
1045573
def average(sequence, key):
    """"""
    return sum(map(key, sequence)) / float(len(sequence))
383396
def mse(exp, obs):
    
    assert len(exp) == len(obs)
    return numpy.mean((numpy.array(exp) - numpy.array(obs)) ** 2)
145587
def interpret_maskval(paramDict):
    
    # interpret user specified final_maskval value to use for initializing
    # output SCI array...
    if 'maskval' not in paramDict:
        return 0
    maskval = paramDict['maskval']
    if maskval is None:
        maskval = np.nan
    else:
        maskval = float(maskval) # just to be clear and absolutely sure...
    return maskval
1227963
private long getTime(Date start, Date end)
   {
      long total = 0;
      if (start != null && end != null)
      {
         Date startTime = DateHelper.getCanonicalTime(start);
         Date endTime = DateHelper.getCanonicalTime(end);

         Date startDay = DateHelper.getDayStartDate(start);
         Date finishDay = DateHelper.getDayStartDate(end);

         //
         // Handle the case where the end of the range is at midnight -
         // this will show up as the start and end days not matching
         //
         if (startDay.getTime() != finishDay.getTime())
         {            
            endTime = DateHelper.addDays(endTime, 1);
         }

         total = (endTime.getTime() - startTime.getTime());
      }
      return (total);
   }
790011
def moving_average(data, periods, type='simple'):
    
    data = np.asarray(data)
    if type == 'simple':
        weights = np.ones(periods)
    else:
        weights = np.exp(np.linspace(-1., 0., periods))

    weights /= weights.sum()

    mavg = np.convolve(data, weights, mode='full')[:len(data)]
    mavg[:periods] = mavg[periods]
    return mavg
29968
def _full_to_yearly_ts(self, arr, dt):
        """"""
        time_defined = self.def_time and not ('av' in self.dtype_in_time)
        if time_defined:
            arr = utils.times.yearly_average(arr, dt)
        return arr
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
237590
def analyze(self, time: int=None) -> typing.Tuple[float, float, int, int]:
        
        if not time:
            time = int(len(self.times) / 2)
        if self.domains[time] == 0:
            yhat, residuals, mean_residual, error = self._get_fit(time)
            yhat_p = self.ddiff(yhat)
            yhat_pp = self.ddiff(yhat_p)
            noise = self._get_noise(residuals)
            curvature = (1 / self.ratio) * (1 / len(yhat_pp)) * np.sqrt(si.simps(yhat_pp ** 2))
            rng = (self.ratio * (np.max(self.averagedata[:, time]) -
                                 np.min(self.averagedata[:, time])))
            dmn = self.ratio * len(self.averagedata[:, time])

            self.noises[time] = np.log10(noise)
            self.curves[time] = np.log10(curvature)
            self.ranges[time] = np.log10(rng)
            self.domains[time] = np.log10(dmn)
        return self.noises[time], self.curves[time], self.ranges[time], self.domains[time]
1295320
def avg_resp_time(self):
        
        if not self._runtimes:
            return 0
        return round(sum(self._runtimes) / len(self._runtimes), 2)
954632
def hull_moving_average(data, period):
    
    catch_errors.check_for_period_error(data, period)
    hma = wma(
        2 * wma(data, int(period/2)) - wma(data, period), int(np.sqrt(period))
        )
    return hma