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:
- Wikipedia: Time series
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface dev.nm.stat.timeseries.datastructure.univariate.UnivariateTimeSeries
UnivariateTimeSeries.Entry<T>
-
-
Constructor Summary
Constructors Constructor Description GenericTimeTimeSeries(T[] timestamps, double[] values)Construct a univariate time series from timestamps and values.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GenericTimeTimeSeries<T>diff(int d)Construct an instance ofGenericTimeTimeSeriesby taking the first differencedtimes.GenericTimeTimeSeries<T>drop(int nItems)Construct an instance ofGenericTimeTimeSeriesby dropping the leadingnItemsentries.booleanequals(Object obj)doubleget(int i)Get the i-th value.doubleget(T t)Get the value at timet.inthashCode()Iterator<UnivariateTimeSeries.Entry<T>>iterator()intsize()Get the length of the time series.Ttime(int index)Get the i-th time.T[]timestamps()Get all the timestamps.double[]toArray()Convert this time series into an array, discarding the timestamps.StringtoString()-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
GenericTimeTimeSeries
public GenericTimeTimeSeries(T[] timestamps, double[] values)
Construct a univariate time series from timestamps and values.- Parameters:
timestamps- the timestampsvalues- the values
-
-
Method Detail
-
size
public int size()
Description copied from interface:TimeSeriesGet the length of the time series.- Specified by:
sizein interfaceTimeSeries<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:
iteratorin interfaceIterable<T extends Comparable<? super T>>
-
toArray
public double[] toArray()
Description copied from interface:UnivariateTimeSeriesConvert this time series into an array, discarding the timestamps.- Specified by:
toArrayin interfaceUnivariateTimeSeries<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 timet.- 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 ofGenericTimeTimeSeriesby dropping the leadingnItemsentries.- Parameters:
nItems- the number of leading entries to be dropped- Returns:
- a
GenericTimeTimeSeries
-
diff
public GenericTimeTimeSeries<T> diff(int d)
Construct an instance ofGenericTimeTimeSeriesby taking the first differencedtimes.- Parameters:
d- the number of differences- Returns:
diff(x, lag = 1, differences = d)as in DoubleUtils
-
-