org.openuat.sensors
Class TimeSeries_Int

java.lang.Object
  extended by org.openuat.sensors.TimeSeries_Int
All Implemented Interfaces:
SamplesSink_Int

public class TimeSeries_Int
extends java.lang.Object
implements SamplesSink_Int

This class represents a possibly multi-dimensional time series of a single sensor. It computes simply statistical values, can distinguish active from passive segments, and offers some convenience methods. In contrast to the TimeSeries class, this one uses int values for samples, and is thus better suited for resource limited scenarios like J2ME.

Version:
1.0
Author:
Rene Mayrhofer

Nested Class Summary
static interface TimeSeries_Int.Parameters
          This interface represents the parameters that must be reasonably set when initializing a time series that reads from sensors instead of from other time series.
 
Field Summary
static int MAXIMUM_VALUE
           
 
Constructor Summary
TimeSeries_Int(int windowSize)
          Initializes the time series circular buffer with the specified window size.
 
Method Summary
 void addNextStageSink(SamplesSink_Int sink)
          Registers a sink, which will receive all new values as they are sampled.
 void addSample(int sample, int sampleNum)
          Adds a new sample to the time series in-memory buffer, updates statistics and may forward to the next stage.
 int getActiveVarianceThreshold()
          Gets the current value of activeVarianceThreshold.
 boolean getDifferencing()
          Gets the current value of differencing.
 int getDisivsor()
          Gets the current value of divisor.
 int getMultiplicator()
          Gets the current value of multiplicator.
 int getOffset()
          Gets the current value of offset.
 int[] getSamplesInWindow()
          Returns all samples currently contained in the time window.
 boolean getSubtractTotalMean()
          Gets the current value of subtractTotalMean.
 boolean getSubtractWindowMean()
          Gets the current value of subtractWindowMean.
 int getTotalMean()
          Returns the mean over all values added to this time series since its construction.
 int getTotalVariance()
          Returns the variance over all values added to this time series since its construction.
 int getWindowMean()
          Returns the mean over all values in the time series buffer, i.e. the last window size samples.
 int getWindowVariance()
          Returns the variance over all values in the time series buffer, i.e. the last window size samples.
 boolean removeSink(SamplesSink_Int sink)
          Removes a previously registered sink.
 void reset()
          Resets the time series to the state as created when freshly constructing it.
 void segmentEnd(int indexNotUsed)
          Dummy implementation of SamplesSink_Int.segmentEnd.
 void segmentStart(int indexNotUsed)
          Dummy implementation of SamplesSink_Int.segmentStart.
 void setActiveVarianceThreshold(int activeVarianceThreshold)
          Sets the current value of activeVarianceThreshold.
 void setDifferencing(boolean differencing)
          Sets the current value of differencing.
 void setDivisor(int divisor)
          Sets the current value of divisor.
 void setMultiplicator(int multiplicator)
          Sets the current value of multiplicator.
 void setOffset(int offset)
          Sets the current value of offset.
 void setParameters(TimeSeries_Int.Parameters pars)
          Sets the multiplicator, divisor, and the offset according to the given parameters object.
 void setSubtractTotalMean(boolean subtractTotalMean)
          Sets the current value of subtractTotalMean.
 void setSubtractWindowMean(boolean subtractWindowMean)
          Sets the current value of subtractWindowMean.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MAXIMUM_VALUE

public static final int MAXIMUM_VALUE
See Also:
Constant Field Values
Constructor Detail

TimeSeries_Int

public TimeSeries_Int(int windowSize)
Initializes the time series circular buffer with the specified window size.

Parameters:
windowSize - Specifies the number of past samples kept in memory and used for computing the window mean and variance.
Method Detail

reset

public void reset()
Resets the time series to the state as created when freshly constructing it. However, it does not reset the parameters offset, multiplicator, subtractWindowMean, and subtractTotalMean.


addSample

public void addSample(int sample,
                      int sampleNum)
Adds a new sample to the time series in-memory buffer, updates statistics and may forward to the next stage.

Specified by:
addSample in interface SamplesSink_Int
Parameters:
sample - The sample value to add.
sampleNum - The number of the sample to add. As this class keeps internal count of how many samples have already been added, this is used for checking that all samples are received and no duplicates happen. index is assumed to start at 0.

segmentStart

public void segmentStart(int indexNotUsed)
Dummy implementation of SamplesSink_Int.segmentStart. Does nothing.

Specified by:
segmentStart in interface SamplesSink_Int
Parameters:
indexNotUsed - The index at which the active segment starts.

segmentEnd

public void segmentEnd(int indexNotUsed)
Dummy implementation of SamplesSink_Int.segmentEnd. Does nothing.

Specified by:
segmentEnd in interface SamplesSink_Int
Parameters:
indexNotUsed - The index at which the active segment ends.

addNextStageSink

public void addNextStageSink(SamplesSink_Int sink)
Registers a sink, which will receive all new values as they are sampled.

Parameters:
sink - The sink to push new pre-processed samples to.

removeSink

public boolean removeSink(SamplesSink_Int sink)
Removes a previously registered sink.

Parameters:
sink - The sink to stop pushing samples to.
Returns:
true if removed, false if not (i.e. if it has not been added previously).

getTotalMean

public int getTotalMean()
Returns the mean over all values added to this time series since its construction.


getTotalVariance

public int getTotalVariance()
Returns the variance over all values added to this time series since its construction.


getWindowMean

public int getWindowMean()
Returns the mean over all values in the time series buffer, i.e. the last window size samples.


getWindowVariance

public int getWindowVariance()
Returns the variance over all values in the time series buffer, i.e. the last window size samples.


getSamplesInWindow

public int[] getSamplesInWindow()
Returns all samples currently contained in the time window. These are already normalized.


getOffset

public int getOffset()
Gets the current value of offset. This will be applied to all incoming values before they are stored in the buffer, i.e. all consecutive processing steps.

Returns:
The current value of offset.
See Also:
offset

setOffset

public void setOffset(int offset)
Sets the current value of offset. This will be applied to all incoming values before they are stored in the buffer, i.e. all consecutive processing steps.

Parameters:
offset - The current value of offset.
See Also:
offset

getMultiplicator

public int getMultiplicator()
Gets the current value of multiplicator. This will be applied to all incoming values before they are stored in the buffer, i.e. all consecutive processing steps.

Returns:
The current value of multiplicator.
See Also:
multiplicator

setMultiplicator

public void setMultiplicator(int multiplicator)
Sets the current value of multiplicator. This will be applied to all incoming values before they are stored in the buffer, i.e. all consecutive processing steps.

Parameters:
multiplicator - The current value of multiplicator.
See Also:
multiplicator

getDisivsor

public int getDisivsor()
Gets the current value of divisor. This will be applied to all incoming values before they are stored in the buffer, i.e. all consecutive processing steps.

Returns:
The current value of divisor.
See Also:
divisor

setDivisor

public void setDivisor(int divisor)
Sets the current value of divisor. This will be applied to all incoming values before they are stored in the buffer, i.e. all consecutive processing steps.

Parameters:
multiplicator - The current value of divisor.
See Also:
divisor

getSubtractWindowMean

public boolean getSubtractWindowMean()
Gets the current value of subtractWindowMean.

Returns:
The current value of subtractWindowMean.
See Also:
subtractWindowMean

setSubtractWindowMean

public void setSubtractWindowMean(boolean subtractWindowMean)
Sets the current value of subtractWindowMean.

Parameters:
subtractWindowMean - The current value of subtractWindowMean.
See Also:
subtractWindowMean

getSubtractTotalMean

public boolean getSubtractTotalMean()
Gets the current value of subtractTotalMean.

Returns:
The current value of subtractTotalMean.
See Also:
subtractTotalMean

setSubtractTotalMean

public void setSubtractTotalMean(boolean subtractTotalMean)
Sets the current value of subtractTotalMean.

Parameters:
subtractTotalMean - The current value of subtractTotalMean.
See Also:
subtractTotalMean

getDifferencing

public boolean getDifferencing()
Gets the current value of differencing.

Returns:
The current value of differencing.
See Also:
differencing

setDifferencing

public void setDifferencing(boolean differencing)
Sets the current value of differencing.

Parameters:
differencing - The current value of differencing.
See Also:
differencing

getActiveVarianceThreshold

public int getActiveVarianceThreshold()
Gets the current value of activeVarianceThreshold. Note that this threshold applies to the normalized, not the original value range.

Returns:
The current value of activeVarianceThreshold.
See Also:
activeVarianceThreshold

setActiveVarianceThreshold

public void setActiveVarianceThreshold(int activeVarianceThreshold)
Sets the current value of activeVarianceThreshold. Note that this threshold applies to the normalized, not the original value range.

Parameters:
activeVarianceThreshold - The current value of activeVarianceThreshold.
See Also:
activeVarianceThreshold

setParameters

public void setParameters(TimeSeries_Int.Parameters pars)
Sets the multiplicator, divisor, and the offset according to the given parameters object.

Parameters:
pars - An object that can be queried for the values to be set.


2005-2006, Rene Mayrhofer.