Class GenericTimeTimeSeries<T extends Comparable<? super T>>

java.lang.Object
dev.nm.stat.timeseries.datastructure.univariate.GenericTimeTimeSeries<T>
Type Parameters:
T - the timestamp type
All Implemented Interfaces:
TimeSeries<T,Double,UnivariateTimeSeries.Entry<T>>, UnivariateTimeSeries<T,UnivariateTimeSeries.Entry<T>>, Iterable<UnivariateTimeSeries.Entry<T>>
Direct Known Subclasses:
DateTimeTimeSeries

public class GenericTimeTimeSeries<T extends Comparable<? super T>> extends Object implements UnivariateTimeSeries<T,UnivariateTimeSeries.Entry<T>>
This is a univariate time series indexed by some notion of time. This implementation explicitly remembers all data in memory. It is appropriate for a short time series.
See Also:
  • Constructor Details

    • GenericTimeTimeSeries

      public GenericTimeTimeSeries(T[] timestamps, double[] values)
      Construct a univariate time series from timestamps and values.
      Parameters:
      timestamps - the timestamps
      values - the values
  • Method Details

    • size

      public int size()
      Description copied from interface: TimeSeries
      Get the length of the time series.
      Specified by:
      size in interface TimeSeries<T extends Comparable<? super T>,Double,UnivariateTimeSeries.Entry<T extends Comparable<? super T>>>
      Returns:
      the time series length
    • iterator

      public Iterator<UnivariateTimeSeries.Entry<T>> iterator()
      Specified by:
      iterator in interface Iterable<T extends Comparable<? super T>>
    • toArray

      public double[] toArray()
      Description copied from interface: UnivariateTimeSeries
      Convert this time series into an array, discarding the timestamps.
      Specified by:
      toArray in interface UnivariateTimeSeries<T extends Comparable<? super T>,UnivariateTimeSeries.Entry<T extends Comparable<? super T>>>
      Returns:
      the array representation of the time series
    • get

      public double get(int i)
      Get the i-th value.
      Parameters:
      i - the position index
      Returns:
      the i-th value
    • get

      public double get(T t)
      Get the value at time t.
      Parameters:
      t - a timestamp
      Returns:
      the value at time t
    • time

      public T time(int index)
      Get the i-th time.
      Parameters:
      index - the position index
      Returns:
      the i-th timestamp
    • timestamps

      public T[] timestamps()
      Get all the timestamps.
      Returns:
      the timestamps
    • drop

      public GenericTimeTimeSeries<T> drop(int nItems)
      Construct an instance of GenericTimeTimeSeries by dropping the leading nItems entries.
      Parameters:
      nItems - the number of leading entries to be dropped
      Returns:
      a GenericTimeTimeSeries
    • diff

      public GenericTimeTimeSeries<T> diff(int d)
      Construct an instance of GenericTimeTimeSeries by taking the first difference d times.
      Parameters:
      d - the number of differences
      Returns:
      diff(x, lag = 1, differences = d) as in DoubleUtils
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object obj)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object