SuanShu, a Java numerical and statistical library

com.numericalmethod.suanshu.stats.timeseries.multivariate
Class GenericTimeTimeSeries<T extends java.lang.Comparable<T>>

java.lang.Object
  extended by com.numericalmethod.suanshu.stats.timeseries.multivariate.GenericTimeTimeSeries<T>
Type Parameters:
T - the Comparable type
All Implemented Interfaces:
MultiVariateTimeSeries<T>, TimeSeries<T,Vector>

public class GenericTimeTimeSeries<T extends java.lang.Comparable<T>>
extends java.lang.Object
implements MultiVariateTimeSeries<T>

This is an implementation of a multivariate time series indexed by some notion of time.

This implementation explicitly remembers all data in memory. It is appropriate for short time series.

GenericTimeTimeSeries is immutable.

See Also:
Wikipedia: Time series

Nested Class Summary
 class GenericTimeTimeSeries.Iterator
          the Iterator used to read a GenericTimeTimeSeries
 
Nested classes/interfaces inherited from interface com.numericalmethod.suanshu.stats.timeseries.multivariate.MultiVariateTimeSeries
MultiVariateTimeSeries.Entry<T>
 
Constructor Summary
GenericTimeTimeSeries(T[] timestamps, double[][] values)
           
GenericTimeTimeSeries(T[] timestamps, Matrix values)
           
GenericTimeTimeSeries(T[] timestamps, Vector[] values)
          Construct a GenericTimeTimeSeries from an array of timestamps and an array of vectors.
 
Method Summary
 GenericTimeTimeSeries<T> diff(int d)
          Create a new and independent GenericTimeTimeSeries by taking the first difference.
 int dimension()
          Get the dimension of the multivariate time series.
 GenericTimeTimeSeries<T> drop(int nItems)
          Create a new and independent GenericTimeTimeSeries by dropping the leading nItems entries, the most backward in time entries.
 boolean equals(java.lang.Object obj)
           
 Vector get(int index)
          Get the value at position index.
 int hashCode()
           
 GenericTimeTimeSeries.Iterator iterator()
          Get an Iterator to read this multivariate time series.
 int size()
          the length of the time series
 T time(int index)
          Get the time at position index.
 T[] timestamps()
          Get all the timestamps.
 Vector[] toArray()
           
 Matrix toMatrix()
          Convert this multivariate time series into an m x n matrix, where m is the dimension, and n the length.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

GenericTimeTimeSeries

public GenericTimeTimeSeries(T[] timestamps,
                             Vector[] values)
Construct a GenericTimeTimeSeries from an array of timestamps and an array of vectors.

The two arrays must be of the same length.

Parameters:
timestamps - an array of timestamps
values - an array of vectors

GenericTimeTimeSeries

public GenericTimeTimeSeries(T[] timestamps,
                             double[][] values)

GenericTimeTimeSeries

public GenericTimeTimeSeries(T[] timestamps,
                             Matrix values)
Method Detail

dimension

public int dimension()
Get the dimension of the multivariate time series.

Specified by:
dimension in interface MultiVariateTimeSeries<T extends java.lang.Comparable<T>>
Returns:
the dimension

size

public int size()
Description copied from interface: TimeSeries
the length of the time series

Specified by:
size in interface TimeSeries<T extends java.lang.Comparable<T>,Vector>
Returns:
the size

iterator

public GenericTimeTimeSeries.Iterator iterator()
Description copied from interface: MultiVariateTimeSeries
Get an Iterator to read this multivariate time series.

Specified by:
iterator in interface MultiVariateTimeSeries<T extends java.lang.Comparable<T>>
Specified by:
iterator in interface TimeSeries<T extends java.lang.Comparable<T>,Vector>
Returns:
an iterator

toArray

public Vector[] toArray()

toMatrix

public Matrix toMatrix()
Description copied from interface: MultiVariateTimeSeries
Convert this multivariate time series into an m x n matrix, where m is the dimension, and n the length.

Specified by:
toMatrix in interface MultiVariateTimeSeries<T extends java.lang.Comparable<T>>
Returns:
the matrix representation of this time series

get

public Vector get(int index)
Get the value at position index.

Parameters:
index - the position index
Returns:
the index-th value

time

public T time(int index)
Get the time at position index.

Parameters:
index - the position index
Returns:
the index-th timestamp

timestamps

public T[] timestamps()
Get all the timestamps.

Returns:
the timestamps

drop

public GenericTimeTimeSeries<T> drop(int nItems)
Create a new and independent GenericTimeTimeSeries by dropping the leading nItems entries, the most backward in time entries.

Parameters:
nItems - the number of leading entries to be dropped
Returns:
a new and independent time series

diff

public GenericTimeTimeSeries<T> diff(int d)
Create a new and independent GenericTimeTimeSeries by taking the first difference.

Parameters:
d - the number of differences
Returns:
diff(x, lag = 1, differences = d) as in R

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

SuanShu, a Java numerical and statistical library

Copyright © 2011 Numerical Method Inc. Ltd. All Rights Reserved.