org.openuat.features
Class TimeSeriesUtil

java.lang.Object
  extended by org.openuat.features.TimeSeriesUtil

public class TimeSeriesUtil
extends java.lang.Object

This class contains utility functions for dealing with time series.

Version:
1.1, changes to 1.0: added integer versions of the helper methods
Author:
Rene Mayrhofer

Constructor Summary
TimeSeriesUtil()
           
 
Method Summary
static double[][] cutSegmentsToEqualLength(double[] segment1, double[] segment2)
          This method equalizes the length of two time series segments by cutting the longer to the length of the shorter.
static int[][] cutSegmentsToEqualLength(int[] segment1, int[] segment2)
          This is the integer variant of cutSegmentsToEqualLength(double[], double[]).
static double[] decodeVector(byte[] b)
          Encodes a byte vector as produced by encodeVector to its original form.
static byte[] encodeVector(double[] a)
          Encodes a double vector as byte vector so that it can be transmitted over the network.
static int getMaxInd(int numFftPoints, int samplerate, int cutOffFrequency)
          Compute the maximum index of a vector of FFT coefficients that needs to considered when using them only up to the specified cut-off frequency.
static double[][] slice(double[] segment, int maxSegmentLength, int segmentSkip)
          Slices a time series into multiple parts pf a specified length.
static int[][] slice(int[] segment, int maxSegmentLength, int segmentSkip)
          This is the integer version of slice(double[], int, int).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimeSeriesUtil

public TimeSeriesUtil()
Method Detail

cutSegmentsToEqualLength

public static double[][] cutSegmentsToEqualLength(double[] segment1,
                                                  double[] segment2)
This method equalizes the length of two time series segments by cutting the longer to the length of the shorter.

Parameters:
segment1 - The first time series segment to use.
segment2 - The second time series segment to use.
Returns:
An array of two time series segments. Both arrays will have the same length and will contain copies of the first parts of segment1 and segment2 respectively. That is, return[0] will contain segment1[0:len] and return[1] will contain segment2[0:len] with len being the minimum of segment1.length and segment2.length.

cutSegmentsToEqualLength

public static int[][] cutSegmentsToEqualLength(int[] segment1,
                                               int[] segment2)
This is the integer variant of cutSegmentsToEqualLength(double[], double[]).


slice

public static double[][] slice(double[] segment,
                               int maxSegmentLength,
                               int segmentSkip)
Slices a time series into multiple parts pf a specified length.

Parameters:
segment - The time series segment to slice.
maxSegmentLength - The number of samples that the slices should have. If set to -1, no slicing will happen.
segmentSkip - How many samples to skip when generating the next slice. Slices will overlap by (maxSegmentLength-segmentSkip) samples.
Returns:
An array of slices generated from the time series. If segment is <=maxSegmentLength or maxSegmentLength is <=0, then no slicing will be done and the original time series passed in segment will be returned as the first and only element in this array. Otherwise, all elements of the returned array will have the same length, namely maxSegmentLength samples. Attention:If segment can not be divided into slices without remainder, the remainder will be ignored and will not be returned.

slice

public static int[][] slice(int[] segment,
                            int maxSegmentLength,
                            int segmentSkip)
This is the integer version of slice(double[], int, int).


getMaxInd

public static int getMaxInd(int numFftPoints,
                            int samplerate,
                            int cutOffFrequency)
Compute the maximum index of a vector of FFT coefficients that needs to considered when using them only up to the specified cut-off frequency.


encodeVector

public static byte[] encodeVector(double[] a)
Encodes a double vector as byte vector so that it can be transmitted over the network. No assumptions should be made about the byte vector contents, and the coding may change in future versions to optimmize runtime or coding size. The result should be decoded wie decodeVector.

See Also:
decodeVector(byte[])

decodeVector

public static double[] decodeVector(byte[] b)
Encodes a byte vector as produced by encodeVector to its original form. Some accuracy may be lost.

See Also:
encodeVector(double[])


2005-2006, Rene Mayrhofer.