/// <summary>
        /// Get data between two points in raw form.
        /// </summary>
        /// <param name="desc">The data description.</param>
        /// <param name="index">The index to get data from.</param>
        /// <returns>The requested data.</returns>
        private double GetDataRAW(TemporalDataDescription desc,
                                  int index)
        {
            TemporalPoint point = this.points[index - 1];

            return(point[desc.Index]);
        }
        /// <summary>
        /// Create a temporal data point using a sequence number. They can also be
        /// created using time. No two points should have the same sequence number.
        /// </summary>
        /// <param name="sequence">The sequence number.</param>
        /// <returns>A new TemporalPoint object.</returns>
        public virtual TemporalPoint CreatePoint(int sequence)
        {
            TemporalPoint point = new TemporalPoint(this.descriptions.Count);

            point.Sequence = sequence;
            this.points.Add(point);
            return(point);
        }
        /// <summary>
        /// Create a temporal point from a time. Using the grandularity each date is
        /// given a unique sequence number. No two dates that fall in the same
        /// grandularity should be specified.
        /// </summary>
        /// <param name="when">The time that this point should be created at.</param>
        /// <returns>The point TemporalPoint created.</returns>
        public virtual TemporalPoint CreatePoint(DateTime when)
        {
            int           sequence = GetSequenceFromDate(when);
            TemporalPoint point    = new TemporalPoint(this.descriptions.Count);

            point.Sequence = sequence;
            this.points.Add(point);
            return(point);
        }
        /// <summary>
        /// Calculate the index to start at.
        /// </summary>
        /// <returns>The starting point.</returns>
        public virtual int CalculateStartIndex()
        {
            for (int i = 0; i < this.points.Count; i++)
            {
                TemporalPoint point = this.points[i];
                if (this.IsPointInRange(point))
                {
                    return(i);
                }
            }

            return(-1);
        }
        /// <summary>
        /// Get data between two points in delta form.
        /// </summary>
        /// <param name="desc">The data description.</param>
        /// <param name="index">The index to get data from.</param>
        /// <returns>The requested data.</returns>
        private double GetDataDeltaChange(TemporalDataDescription desc,
                                          int index)
        {
            if (index == 0)
            {
                return(0.0);
            }
            TemporalPoint point         = this.points[index];
            TemporalPoint previousPoint = this.points[index - 1];

            return(point[desc.Index]
                   - previousPoint[desc.Index]);
        }
        /// <summary>
        /// Get data between two points in percent form.
        /// </summary>
        /// <param name="desc">The data description.</param>
        /// <param name="index">The index to get data from.</param>
        /// <returns>The requested data.</returns>
        private double GetDataPercentChange(TemporalDataDescription desc,
                                            int index)
        {
            if (index == 0)
            {
                return(0.0);
            }
            TemporalPoint point         = this.points[index];
            TemporalPoint previousPoint = this.points[index - 1];
            double        currentValue  = point[desc.Index];
            double        previousValue = previousPoint[desc.Index];

            return((currentValue - previousValue) / previousValue);
        }
 /// <summary>
 /// 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.
 /// </summary>
 /// <param name="point">The point to consider.</param>
 /// <returns>True if the point is within the range.</returns>
 public virtual bool IsPointInRange(TemporalPoint point)
 {
     return((point.Sequence >= this.LowSequence) && (point.Sequence <= this.HighSequence));
 }