/** * Create a temporal point from a time. Using the granularity each date is given a unique sequence * number. No two dates that fall in the same granularity should be specified. * * @param when The time that this point should be created at. * @return The point TemporalPoint created. */ public TemporalPoint createPoint(final Date when) { final int sequence = getSequenceFromDate(when); final TemporalPoint point = new TemporalPoint(this.descriptions.size()); point.setSequence(sequence); this.points.add(point); return point; }
/** * Get data between two points in delta form. * * @param desc The data description. * @param index The index to get data from. * @return The requested data. */ private double getDataDeltaChange(final TemporalDataDescription desc, final int index) { if (index == 0) { return 0.0; } final TemporalPoint point = this.points.get(index); final TemporalPoint previousPoint = this.points.get(index - 1); return point.getData(desc.getIndex()) - previousPoint.getData(desc.getIndex()); }
/** * Get data between two points in percent form. * * @param desc The data description. * @param index The index to get data from. * @return The requested data. */ private double getDataPercentChange(final TemporalDataDescription desc, final int index) { if (index == 0) { return 0.0; } final TemporalPoint point = this.points.get(index); final TemporalPoint previousPoint = this.points.get(index - 1); final double currentValue = point.getData(desc.getIndex()); final double previousValue = previousPoint.getData(desc.getIndex()); return (currentValue - previousValue) / previousValue; }
/** * Is the specified point within the range. If a point is in the selection range, then the point * will be used to generate the training sets. * * @param point The point to consider. * @return True if the point is within the range. */ public boolean isPointInRange(final TemporalPoint point) { return (point.getSequence() >= getLowSequence()) && (point.getSequence() <= getHighSequence()); }
/** * Get data between two points in raw form. * * @param desc The data description. * @param index The index to get data from. * @return The requested data. */ private double getDataRAW(final TemporalDataDescription desc, final int index) { final TemporalPoint point = this.points.get(index - 1); return point.getData(desc.getIndex()); }