/** Returns an iterator of frequencyDist names */
    private Iterator<String> freqNames(org.apache.commons.math.stat.Frequency freq) {
      return Iterators.transform(
          freq.valuesIterator(),
          new Function<Comparable<?>, String>() {

            @Override
            public String apply(Comparable<?> input) {
              return input.toString();
            }
          });
    }
  @Override
  public void handleEvent(final PersonArrivalEvent arrivalEvent) {
    this.doReset();
    PersonDepartureEvent departureEvent = this.pendantDepartures.remove(arrivalEvent.getPersonId());
    String mode = arrivalEvent.getLegMode();
    Frequency frequency;
    ResizableDoubleArray rawDataElement;

    // Consistency check...
    if (departureEvent == null) {
      log.warn(
          "One arrival do not correspond to any departure for agent " + arrivalEvent.getPersonId());
      return;
    } else if (!mode.equals(departureEvent.getLegMode())) {
      log.warn("Departure and arrival have uncompatible modes!");
      return;
    }
    // consistency check... DONE

    if (this.frequencies.containsKey(mode)) {
      frequency = this.frequencies.get(mode);
      rawDataElement = this.rawData.get(mode);
    } else {
      frequency = new Frequency();
      rawDataElement = new ResizableDoubleArray();

      this.frequencies.put(mode, frequency);
      this.rawData.put(mode, rawDataElement);
    }
    double xyVal = 0.0;
    if (this.xy.equals("times")) {
      xyVal = this.computeTimes(arrivalEvent, departureEvent);
    } else {
      xyVal = this.computeDistances(arrivalEvent, departureEvent);
    }
    // remember data
    frequency.addValue(xyVal);
    rawDataElement.addElement(xyVal);
  }