Java Code Examples for org.apache.commons.math.stat.descriptive.moment.Mean#increment()

The following examples show how to use org.apache.commons.math.stat.descriptive.moment.Mean#increment() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AvroMixedMapReduce.java    From hiped2 with Apache License 2.0 6 votes vote down vote up
public void reduce(Text key,
                   Iterator<DoubleWritable> values,
                   OutputCollector<AvroWrapper<StockAvg>,
                       NullWritable> output,
                   Reporter reporter) throws IOException {

  Mean mean = new Mean();
  while (values.hasNext()) {
    mean.increment(values.next().get());
  }
  StockAvg avg = new StockAvg();
  avg.setSymbol(key.toString());
  avg.setAvg(mean.getResult());
  output.collect(new AvroWrapper<StockAvg>(avg),
      NullWritable.get());
}
 
Example 2
Source File: AvroKeyValueMapReduce.java    From hiped2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void reduce(Text key, Iterable<DoubleWritable> values, Context context) throws IOException, InterruptedException {
  Mean mean = new Mean();
  for (DoubleWritable val: values) {
    mean.increment(val.get());
  }
  StockAvg avg = new StockAvg();
  avg.setSymbol(key.toString());
  avg.setAvg(mean.getResult());
  context.write(key, new AvroValue<StockAvg>(avg));
}
 
Example 3
Source File: AvroRecordMapReduce.java    From hiped2 with Apache License 2.0 5 votes vote down vote up
@Override
public void reduce(Utf8 symbol, Iterable<Stock> stocks,
                   AvroCollector<StockAvg> collector,
                   Reporter reporter) throws IOException {

  Mean mean = new Mean();
  for (Stock stock : stocks) {
    mean.increment(stock.getOpen());
  }
  StockAvg avg = new StockAvg();
  avg.setSymbol(symbol.toString());
  avg.setAvg(mean.getResult());

  collector.collect(avg);
}
 
Example 4
Source File: ExampleParquetMapReduce.java    From hiped2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void reduce(Text key, Iterable<DoubleWritable> values, Context context) throws IOException, InterruptedException {
  Mean mean = new Mean();
  for (DoubleWritable val : values) {
    mean.increment(val.get());
  }
  Group group = factory.newGroup()
      .append("symbol", key.toString())
      .append("avg", mean.getResult());
  context.write(null, group);
}
 
Example 5
Source File: AvroParquetMapReduce.java    From hiped2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void reduce(Text key, Iterable<DoubleWritable> values, Context context) throws IOException, InterruptedException {
  Mean mean = new Mean();
  for (DoubleWritable val : values) {
    mean.increment(val.get());
  }
  StockAvg avg = new StockAvg();
  avg.setSymbol(key.toString());
  avg.setAvg(mean.getResult());
  context.write(null, avg);
}
 
Example 6
Source File: AvroProjectionParquetMapReduce.java    From hiped2 with Apache License 2.0 5 votes vote down vote up
@Override
protected void reduce(Text key, Iterable<DoubleWritable> values, Context context) throws IOException, InterruptedException {
  Mean mean = new Mean();
  for (DoubleWritable val : values) {
    mean.increment(val.get());
  }
  StockAvg avg = new StockAvg();
  avg.setSymbol(key.toString());
  avg.setAvg(mean.getResult());
  context.write(null, avg);
}