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 ofGenericTimeTimeSeries
by taking the first differenced
times.GenericTimeTimeSeries<T>
drop(int nItems)
Construct an instance ofGenericTimeTimeSeries
by dropping the leadingnItems
entries.boolean
equals(Object obj)
double
get(int i)
Get the i-th value.double
get(T t)
Get the value at timet
.int
hashCode()
Iterator<UnivariateTimeSeries.Entry<T>>
iterator()
int
size()
Get the length of the time series.T
time(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.String
toString()
-
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:TimeSeries
Get the length of the time series.- Specified by:
size
in 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:
iterator
in interfaceIterable<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 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 ofGenericTimeTimeSeries
by dropping the leadingnItems
entries.- Parameters:
nItems
- the number of leading entries to be dropped- Returns:
- a
GenericTimeTimeSeries
-
diff
public GenericTimeTimeSeries<T> diff(int d)
Construct an instance ofGenericTimeTimeSeries
by taking the first differenced
times.- Parameters:
d
- the number of differences- Returns:
diff(x, lag = 1, differences = d)
as in DoubleUtils
-
-