public final class DampedSinusoidFit
extends java.lang.Object
q = Aeγtsin(μt + φ) + C
which is adapted for efficient fitting in the presence of noise. The fits for frequency, offset and growth rate are good in the presence of relatively small noise. However, the estimation of phase and amplitude are relatively poor in the presence of noise. Also, the estimation breaks down when the frequency is near an integer or half integer.Constructor and Description |
---|
DampedSinusoidFit(double[] waveform)
Constructor accepting the entire waveform
|
DampedSinusoidFit(double[] waveform,
int count)
Primary Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
calculateFittedWaveform(double[] positions,
double[] waveform)
Convenience method to calculate the fitted waveform over the specified positions
|
double |
estimateInitialFrequencyVariance(double signalVariance)
get an estimate of the initial frequency's variance
|
double |
estimateInitialGrowthRateVariance(double signalVariance)
get an estimate of the initial growth rate's variance
|
double |
estimateInitialOffsetVariance(double signalVariance)
get an estimate of the initial offset's variance
|
double |
getAmplitude()
Get the optimized sine-like amplitude
|
double |
getCosineLikePhase()
Get the optimized cosine-like phase (equivalent phase if the fitted equation were of the form of A * damping * cos( mu + phase ) ).
|
double[] |
getFittedWaveform(double[] positions)
Convenience method to calculate the fitted waveform over the specified positions
|
double |
getFrequency()
get the optimized frequency
|
double |
getGrowthRate()
get the optimized growth rate
|
double |
getInitialAmplitude()
Get the sine-like amplitude calculating it if necessary.
|
double |
getInitialCosineLikePhase()
Get the cosine-like phase calculating it if necessary.
|
double |
getInitialFrequency()
get the fitted frequency calculating it if necessary
|
double |
getInitialFrequencyVariance()
get the variance in the initial frequency estimate using the initial estimate of the signal variance
|
double |
getInitialGrowthRate()
get the fitted growth rate calculating it if necessary
|
double |
getInitialGrowthRateVariance()
get the variance in the initial growth rate estimate using the initial estimate of the signal variance
|
double |
getInitialOffset()
get the fitted offset calculating it if necessary
|
double |
getInitialOffsetVariance()
get the variance in the initial offset estimate using the initial estimate of the signal variance
|
double |
getInitialPhase()
Get the sine-like phase estimation calculating it if necessary.
|
double |
getInitialSignalVariance()
get the initial estimat of the signal variance
|
double |
getInitialSineLikePhase()
Get the sine-like phase calculating it if necessary.
|
double[] |
getInitialWaveformError()
get the initial waveform error calculating it if necessary
|
double |
getInitialWaveformRMSError()
get the initial RMS error
|
static DampedSinusoidFit |
getInstance(double[] waveform)
Get a new instance of the damped sinusoid using the entire waveform
|
static DampedSinusoidFit |
getInstance(double[] waveform,
int count)
Get a new instance of the damped sinusoid
|
double |
getOffset()
get the optimized offset
|
double |
getPhase()
get the optimized phase
|
double |
getSignalVariance()
get the optimized estimate of the signal variance
|
double |
getSineLikePhase()
Get the optimized sine-like phase.
|
double[] |
getWaveformError()
get the waveform error
|
double |
getWaveformRMSError()
get the initial RMS error
|
void |
solve(double noiseLevel,
Stopper stopper)
Run the solver to find the best fit
|
void |
solveWithNoise(double noiseLevel)
Run the solver to find the best fit
|
void |
solveWithNoiseMaxEvaluations(double noiseLevel,
int maxEvaluations)
Run the solver to find the best fit
|
void |
solveWithNoiseMaxEvaluationsSatisfaction(double noiseLevel,
int maxEvaluations,
double satisfaction)
Run the solver to find the best fit
|
void |
solveWithNoiseMaxTime(double noiseLevel,
double maxTime)
Run the solver to find the best fit
|
void |
solveWithNoiseMaxTimeSatisfaction(double noiseLevel,
double maxTime,
double satisfaction)
Run the solver to find the best fit
|
public DampedSinusoidFit(double[] waveform, int count)
waveform
- data to fitcount
- starting from the beginning of the waveform, the number of items in the waveform to use in the fitpublic DampedSinusoidFit(double[] waveform)
waveform
- data to fitpublic static DampedSinusoidFit getInstance(double[] waveform, int count)
waveform
- data to fitcount
- starting from the beginning of the waveform, the number of items in the waveform to use in the fitpublic static DampedSinusoidFit getInstance(double[] waveform)
waveform
- data to fitpublic void solveWithNoise(double noiseLevel)
noiseLevel
- estimate of the expected noisepublic void solveWithNoiseMaxEvaluations(double noiseLevel, int maxEvaluations)
noiseLevel
- estimate of the expected noisemaxEvaluations
- the maximum number of evaluations to performpublic void solveWithNoiseMaxEvaluationsSatisfaction(double noiseLevel, int maxEvaluations, double satisfaction)
noiseLevel
- estimate of the expected noisemaxEvaluations
- the maximum number of evaluations to performsatisfaction
- the satisfaction target to reach before stoppingpublic void solveWithNoiseMaxTime(double noiseLevel, double maxTime)
noiseLevel
- estimate of the expected noisemaxTime
- the maximum time to wait for the solutionpublic void solveWithNoiseMaxTimeSatisfaction(double noiseLevel, double maxTime, double satisfaction)
noiseLevel
- estimate of the expected noisemaxTime
- the maximum time to wait for the solutionsatisfaction
- the satisfaction target to reach before stoppingpublic void solve(double noiseLevel, Stopper stopper)
noiseLevel
- the noise level used to estimate the error bounds and provide a measure for satisfactionstopper
- the stopper which determines when to stop the solverpublic double getInitialOffset()
public double getInitialOffsetVariance()
public double getInitialSignalVariance()
public double estimateInitialOffsetVariance(double signalVariance)
public double getOffset()
public double getSignalVariance()
public double getInitialGrowthRate()
public double getInitialGrowthRateVariance()
public double estimateInitialGrowthRateVariance(double signalVariance)
public double[] getInitialWaveformError()
public double getInitialWaveformRMSError()
public double getGrowthRate()
public double getInitialFrequency()
public double getInitialFrequencyVariance()
public double estimateInitialFrequencyVariance(double signalVariance)
public double getFrequency()
public double getInitialPhase()
public double getPhase()
public double getSineLikePhase()
public double getCosineLikePhase()
public double[] getWaveformError()
public double getWaveformRMSError()
public double getInitialSineLikePhase()
public double getInitialCosineLikePhase()
public double getInitialAmplitude()
public double getAmplitude()
public double[] getFittedWaveform(double[] positions)
positions
- array of positions over which to calculate the waveformpublic void calculateFittedWaveform(double[] positions, double[] waveform)
positions
- array of positions over which to calculate the waveformarray
- big enough to hold the calculated waveform over each of the positions