record behavior.
@param statistics {Array} sum, max, min, count, avg
@param aggregations {Array} dy (day in week each year), hm(hour of day each month).
10683
function record(name, num, statistics, aggregations, timestamp, callback) {
        timestamp = timestamp || Date.now();
        function recordStats(key) {
            statistics && statistics.forEach(function(stat) {
                    if(stat == 'sum') {
                        multi.hincrby(key, 'sum', num)
                    } else if(scripts[stat]){
                        evalScript(multi, stat, [key, num],[],function(err, result) {
                                if(err) throw err;
                                if(result && result.indexOf('ERR') == 0) {
                                    // console.log(scripts[stat]);
                                    throw new Error(result);
                                }
                        })
                    }
            });
        }
        if(!statistics) statistics = ['sum'];
        if(num == undefined) num = 1;

        var multi = redis.multi();

        granularities.forEach(function(gran) {
                var key = getGranKey(name, gran, timestamp);
                recordStats(key);
                var unitPeriod = gran[0];
                multi.expire(key, points * unitPeriod / 1000);
        });

        if(aggregations) for(var i = 0; i < aggregations.length; i++) {
            var aggr = aggregations[i];
            var key = getAggrKey(name, aggr, timestamp);
            recordStats(key);
        }

        multi.exec(callback || log);
    }
927355
function (stats) {
            if (stats.result) {
              var resultList = stats.result();
              for (var resultIndex = 0; resultIndex < resultList.length; resultIndex++) {
                var result = resultList[resultIndex];

                if (result.stat) {

                  if(result.stat('googActiveConnection') === 'true') {
                    currentStats.localCandidateType = result.stat('googLocalCandidateType');
                    currentStats.remoteCandidateType = result.stat('googRemoteCandidateType');
                    currentStats.transportType = result.stat('googTransportType');
                  }

                  parseAudioStats(result);
                  parseVideoStats(result);
                }
              }
            }

            completion(null, currentStats);
          }
669682
function endStats(stats) {
  stats.end = Date.now();
  stats.duration = stats.end - stats.start;

  return stats;
}
106470
function AggregateByKey(sc, dependencies, reducer, combiner, init, args) {
  Dataset.call(this, sc, dependencies);
  this.combiner = combiner;
  this.reducer = reducer;
  this.init = init;
  this.args = args;
  this.shuffling = true;
  this.executed = false;
  this.buffer = {};
  this.type = 'AggregateByKey';
}
354594
function updateAggregations(response) {
  if(response.hasOwnProperty('aggregations')) {
    aggregationsBox.textContent = JSON.stringify(response.aggregations,
                                                 null, 2);
    show(aggregationsCard);
  }
  else {
    hide(aggregationsCard);
  }
}
541097
public void setAggregateEvaluationResults(java.util.Collection<AggregateEvaluationResult> aggregateEvaluationResults) {
        if (aggregateEvaluationResults == null) {
            this.aggregateEvaluationResults = null;
            return;
        }

        this.aggregateEvaluationResults = new com.amazonaws.internal.SdkInternalList<AggregateEvaluationResult>(aggregateEvaluationResults);
    }
875726
public function aggregateMultipleReports()
    {
        $dataTableRecords = array(self::USERID_ARCHIVE_RECORD);
        $columnsAggregationOperation = null;
        $this->getProcessor()->aggregateDataTableRecords(
            $dataTableRecords,
            $this->maximumRowsInDataTableLevelZero,
            $this->maximumRowsInDataTableLevelZero,
            $columnToSort = 'nb_visits',
            $columnsAggregationOperation,
            $columnsToRenameAfterAggregation = null,
            $countRowsRecursive = array());
    }
1003950
public void statistics(Statistic stats) {
    if(stats != null) {
      log(Level.STATISTICS, stats.getKey() + ": " + stats.formatValue());
    }
  }
103843
function (data) {
    var histogram = data || this.get('data');
    var freqAccessor = function (a) { return a.freq; };
    var osc = d3.max(histogram, freqAccessor) - d3.min(histogram, freqAccessor);
    var mean = d3.mean(histogram, freqAccessor);
    // When the difference between the max and the min values is less than
    // 10 percent of the mean, it's a flat histogram (F)
    if (osc < mean * 0.1) return 'F';
    var sumFreqs = d3.sum(histogram, freqAccessor);
    var freqs = histogram.map(function (bin) {
      return 100 * bin.freq / sumFreqs;
    });

    // The ajus array represents relative growths
    var ajus = freqs.map(function (freq, index) {
      var next = freqs[index + 1];
      if (freq > next) return -1;
      if (Math.abs(freq - next) <= 0.05) return 0;
      return 1;
    });
    ajus.pop();
    var maxAjus = d3.max(ajus);
    var minAjus = d3.min(ajus);
    // If it never grows or shrinks, it returns flat
    if (minAjus === 0 && maxAjus === 0) return 'F';
    else if (maxAjus < 1) return 'L';
    else if (minAjus > -1) return 'J';
    else {
      var uniques = _.uniq(ajus);
      var A_TYPES = [[1, -1], [1, 0, -1], [1, -1, 0], [0, 1, -1]];
      var U_TYPES = [[-1, 1], [-1, 0, 1], [-1, 1, 0], [0, -1, 1]];
      if (A_TYPES.some(function (e) {
        return _.isEqual(e, uniques);
      })) return 'A';
      else if (U_TYPES.some(function (e) {
        return _.isEqual(e, uniques);
      })) return 'U';
      else return 'S';
    }
  }
500521
function groupData(data, dim) {
    var groups = {};

    each(data, function (record) {
      var value = record[dim];
      if (value === undefined) {
        value = record[dim] = DEFAULT_Y;
      }
      if (!groups[value]) {
        groups[value] = [];
      }
      groups[value].push(record);
    });

    return groups;
  }
1147921
func Aggregate(stats []*stat.Stat) (aggregate StatsAggregate) {
	if stats == nil || len(stats) == 0 {
		return StatsAggregate{}
	}

	aggregate = StatsAggregate{Min : stats[0].Value, Max : stats[0].Value, Count : len(stats)}
	sum := 0.0
	for i := range stats {
		v := stats[i].Value

		sum += v

		if v < aggregate.Min {
			aggregate.Min = v
		}

		if v > aggregate.Max {
			aggregate.Max = v
		}
	}
	aggregate.Average = sum / float64(len(stats))

	return
}
1277082
private void tick(long tickIntervalMs) {
        for (int i = 0; i < NUM_AVERAGES; ++i) {
            stat[i].tick(tickIntervalMs);
        }
    }
280067
public void setSamplingStatisticSummaries(java.util.Collection<SamplingStatisticSummary> samplingStatisticSummaries) {
        if (samplingStatisticSummaries == null) {
            this.samplingStatisticSummaries = null;
            return;
        }

        this.samplingStatisticSummaries = new java.util.ArrayList<SamplingStatisticSummary>(samplingStatisticSummaries);
    }
587795
public void record(long timeNano, int numEvents) {
    long leftEndPoint = bucket(timeNano);
    mSeries.put(leftEndPoint, mSeries.getOrDefault(leftEndPoint, 0) + numEvents);
  }
129214
function(stats) {
        return new Map(Object.keys(stats).map(function(key) {
          return [key, stats[key]];
        }));
      }
365496
def aggregate(self):
        
        _, indices, inverse = np.unique(self.record.sample, axis=0,
                                        return_index=True, return_inverse=True)

        # unique also sorts the array which we don't want, so we undo the sort
        order = np.argsort(indices)
        indices = indices[order]

        record = self.record[indices]

        # fix the number of occurrences
        record.num_occurrences = 0
        for old_idx, new_idx in enumerate(inverse):
            new_idx = order[new_idx]
            record[new_idx].num_occurrences += self.record[old_idx].num_occurrences

        # dev note: we don't check the energies as they should be the same
        # for individual samples

        return type(self)(record, self.variables, copy.deepcopy(self.info),
                          self.vartype)
326623
public void logStatistics() {
    LOG.info("Transaction Statistics: write pointer = " + lastWritePointer +
               ", invalid = " + invalid.size() +
               ", in progress = " + inProgress.size() +
               ", committing = " + committingChangeSets.size() +
               ", committed = " + committedChangeSets.size());
  }