public class OffsetCorrectionFilter extends AbstractFilter
Modifier and Type | Field and Description |
---|---|
private float[] |
actual |
private java.util.Queue<java.lang.Float>[] |
buffer |
private int |
bufferSize |
private float[] |
m2 |
private float[] |
mean |
(package private) float[] |
offset |
(package private) float[] |
reference |
sampleSize, source
Constructor and Description |
---|
OffsetCorrectionFilter(SampleProvider source)
Constructor for the offset correction filter using default parameters.
|
OffsetCorrectionFilter(SampleProvider source,
float[] reference)
Constructor for the offset correction filter using default window of 200
samples.
|
OffsetCorrectionFilter(SampleProvider source,
float[] reference,
int bufferSize)
Constructor for the offset correction filter.
|
Modifier and Type | Method and Description |
---|---|
private void |
addSample(int i)
Method to maintain the running mean and variance by adding a new value;
|
void |
fetchSample(float[] sample,
int offset)
Fetches a sample from a sensor or filter.
|
float[] |
getMean()
Returns the mean sample value
|
float[] |
getStandardDeviation()
Returns the standard deviation from the mean sample value
|
private float |
getStandardDeviation(int i) |
private float |
getVariance(int i) |
private void |
removeSample(int i)
Method to maintain the running mean and variance by removing an old value;
|
void |
reset()
Resets the filter
|
private void |
updateStatistics() |
private boolean |
withinLimits(int i) |
sampleSize
float[] offset
float[] reference
private float[] mean
private float[] m2
private float[] actual
private java.util.Queue<java.lang.Float>[] buffer
private int bufferSize
public OffsetCorrectionFilter(SampleProvider source)
source
- source for samplepublic OffsetCorrectionFilter(SampleProvider source, float[] reference)
source
- source for samplereference
- An array with reference values. The array length should match the
sample size.public OffsetCorrectionFilter(SampleProvider source, float[] reference, int bufferSize)
source
- Source for samplereference
- An array with reference values. The array length should match the
sample size.bufferSize
- Number of samples to use for calculating offset errorpublic void fetchSample(float[] sample, int offset)
SampleProvider
fetchSample
in interface SampleProvider
fetchSample
in class AbstractFilter
sample
- The array to store the sample in.offset
- The elements of the sample are stored in the array starting at the offset position.private void updateStatistics()
private boolean withinLimits(int i)
private void addSample(int i)
i
- private void removeSample(int i)
i
- public void reset()
private float getVariance(int i)
private float getStandardDeviation(int i)
public float[] getMean()
public float[] getStandardDeviation()