org.android.activityminer.logic.features.calculators
Class FFTPeakCalculator<T extends Enum<T> & Dimensions>

Package class diagram package FFTPeakCalculator
java.lang.Object
  extended by org.android.activityminer.logic.features.calculators.AbstractCalculator<T,U>
      extended by org.android.activityminer.logic.features.calculators.AbstractCompositeCalculator<T,U>
          extended by org.android.activityminer.logic.features.calculators.AbstractFFTObservationBasedCalculator<T,Integer>
              extended by org.android.activityminer.logic.features.calculators.FFTPeakCalculator<T>
Type Parameters:
T - the enumeration type for the dimensions
All Implemented Interfaces:
EventObserver<FFTCalculatorEvent>, Calculator<Integer>, CompositeCalculator<Integer>, FFTObservationBasedCalulator<T>

public final class FFTPeakCalculator<T extends Enum<T> & Dimensions>
extends AbstractFFTObservationBasedCalculator<T,Integer>

Implementation of a calculator to determine the peak index with the largest magnitude. The peak frequency for peak index i is freq(i)= i /(n * rate (s)). The amplitude of the peak frequency is calculated as normalized magnitude (normalized by observation count n): amp(i)= mag(i)/n.


Field Summary
private  Double peakAmplitude
          The peak amplitude
private  Double peakFrequency
          The peak frequency
private  int peakIndex
          The peak index.
private  double peakMagnitude
          The peak magnitude
private  double sampleRate
          The sample rate in seconds
 
Fields inherited from class org.android.activityminer.logic.features.calculators.AbstractCalculator
dimension, value
 
Constructor Summary
FFTPeakCalculator(FFTCalculator<T> fftCalculator, long sampleRate)
          Constructor
 
Method Summary
 Integer getCompositeValue()
          Does calculate the composite value.
 Integer getInitialValue()
          Method for value initialization.
 Double getPeakAmplitude()
          Getter for the peak frequency
 Double getPeakFrequency()
          Getter for the peak frequency
 void onEvent(ObservableEventSource<? extends FFTCalculatorEvent> eventSource, FFTCalculatorEvent fftComponent)
           
 
Methods inherited from class org.android.activityminer.logic.features.calculators.AbstractFFTObservationBasedCalculator
getFFTCalculator, getFFTComponentCount
 
Methods inherited from class org.android.activityminer.logic.features.calculators.AbstractCompositeCalculator
getValue, reset
 
Methods inherited from class org.android.activityminer.logic.features.calculators.AbstractCalculator
getDimension
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

peakFrequency

private Double peakFrequency
The peak frequency


peakAmplitude

private Double peakAmplitude
The peak amplitude


peakMagnitude

private double peakMagnitude
The peak magnitude


peakIndex

private int peakIndex
The peak index.


sampleRate

private double sampleRate
The sample rate in seconds

Constructor Detail

FFTPeakCalculator

public FFTPeakCalculator(FFTCalculator<T> fftCalculator,
                         long sampleRate)
Constructor

Parameters:
fftCalculator - the FFT Calculator to observe
sampleRate - the sample rate as time-stamp delta in milliseconds between two observations
Method Detail

getPeakAmplitude

public Double getPeakAmplitude()
Getter for the peak frequency

Returns:
the peak frequency

getPeakFrequency

public Double getPeakFrequency()
Getter for the peak frequency

Returns:
the peak frequency

getInitialValue

public final Integer getInitialValue()
Description copied from interface: Calculator
Method for value initialization.

Returns:
the initialized value

getCompositeValue

public final Integer getCompositeValue()
Description copied from interface: CompositeCalculator
Does calculate the composite value.

Specified by:
getCompositeValue in interface CompositeCalculator<Integer>
Overrides:
getCompositeValue in class AbstractFFTObservationBasedCalculator<T extends Enum<T> & Dimensions,Integer>
Returns:
the composite value

onEvent

public void onEvent(ObservableEventSource<? extends FFTCalculatorEvent> eventSource,
                    FFTCalculatorEvent fftComponent)