/**
   * Format data according to the type specified in the description.
   *
   * @param desc The data description.
   * @param index The index to format the data at.
   * @return The formatted data.
   */
  private double formatData(final TemporalDataDescription desc, final int index) {
    final double[] result = new double[1];

    switch (desc.getType()) {
      case DELTA_CHANGE:
        result[0] = getDataDeltaChange(desc, index);
        break;
      case PERCENT_CHANGE:
        result[0] = getDataPercentChange(desc, index);
        break;
      case RAW:
        result[0] = getDataRAW(desc, index);
        break;
      default:
        throw new TemporalError("Unsupported data type.");
    }

    if (desc.getActivationFunction() != null) {
      desc.getActivationFunction().activationFunction(result, 0, result.length);
    }

    return result[0];
  }