|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectutil.PropertyContainer
util.PropertyResources
util.PropertyBundles
vec_math.AbstractFit
vec_math.HarmonicFit
public class HarmonicFit
A fit to a cosine wave with phase shift, variable period to the input data. If writtn as
y_fit=c_0+a_0*cos(ωt)+b_0*sin(ωt),the fitting function y_fit is linear in its three parameters a_0, b_0, and c_0 and only non-linear in ω. Nevertheless, this non-linearity renders this fit much more demanding then the pure linear fit
PhaseRegression, where the period is held fixed. In
applications, where the period is known a priori, this latter class should
be used for fitting. This fitter should be used mainly for sparse data,
to improve a vaguely defined period.
We assign variable names according to OFFSET, AMPLITUDE,
and T0, where t0 and amplitude are calculated from the
linear parameters as
amplitude²=a_0²+b_0² tan(ωt_0)=b_0/a_0;
| Nested Class Summary | |
|---|---|
private static class |
HarmonicFit.HarmonicModel
Our data model. |
| Nested classes/interfaces inherited from class util.PropertyResources |
|---|
PropertyResources.URLResource |
| Field Summary | |
|---|---|
static String |
AMPLITUDE
The name of the amplitude constant. |
private static int |
DEFTINDEX
Default time index. |
private static String |
DEFUNITAMPLITUDE
Default units of the parameters. |
private static String |
DEFUNITOFFSET
Default units of the parameters. |
private static String |
DEFUNITPERIOD
Default units of the parameters. |
private static String |
DEFUNITPHASE
Default units of the parameters. |
private static int |
DEFYINDEX
Default y index. |
private List<Variable> |
fitted
The fitted values to C+A*cos(2pi/P*t+PHI). |
static String |
KEY_EPSILON
Default improvement in chi-2 to induce terminating loop. |
static String |
KEY_EXTERNALERROR
Default external error. |
static String |
KEY_ITER
Default number of maximum iteration in levenberg-marquardt. |
static String |
KEY_LAMBDA
Default starting value for the 'fudge factor' boosting hessian. |
static String |
KEY_PERIOD
This is the main fitting parameter. |
static String |
KEY_TERMINATE
Default number of maximum improvements, if epsilon is reached. |
static String |
KEY_TINDEX
The index of the time, defaults to zero. |
static String |
KEY_UNITAMPLITUDE
The units of the parameters. |
static String |
KEY_UNITOFFSET
The units of the parameters. |
static String |
KEY_UNITPERIOD
The units of the parameters. |
static String |
KEY_UNITPHASE
The units of the parameters. |
static String |
KEY_YINDEX
The index of the measure, defaults to one. |
static String |
OFFSET
The name of the offset constant. |
static String |
PERIOD
period constant. |
private HarmonicFit.HarmonicModel |
phasemodel
The model. |
static String |
T0
The name of the phase constant. |
| Fields inherited from class vec_math.AbstractFit |
|---|
KEY_DEFAULTERROR, KEY_DEFAULTFORMAT, KEY_ERRORFORMAT, KEY_PARAMETERFORMAT |
| Fields inherited from class util.PropertyBundles |
|---|
KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_RESOURCEBUNDLES |
| Fields inherited from class util.PropertyResources |
|---|
KEY_NOINITONCREATE, localurl, locate, POSTFIX_DIR, POSTFIX_EXT, POSTFIX_FILE, POSTFIX_LIST, POSTFIX_URL, urlset |
| Fields inherited from class util.PropertyContainer |
|---|
KEY_LISTSEPARATOR, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR |
| Fields inherited from interface util.ResourceSupplying |
|---|
KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME |
| Fields inherited from interface util.PropertySupplying |
|---|
CONFIG, KEY_CLASS |
| Constructor Summary | |
|---|---|
HarmonicFit(Map<String,String> prop)
Constructs a new regression analyser. |
|
| Method Summary | |
|---|---|
List<Variable> |
fit()
We fit the amplitude and phase plus mgnitude offset only, the period stays constant. |
DataModel |
getDataModel()
Returns the phase model. |
List<Variable> |
getFittedParameters()
Returns the fitted parameters. |
DataModel |
prepareFit(VectorG[] in)
Visualization means performing a linear Regression using GeneralRegression#harmonic. |
boolean |
setInitialCondition(Variable p)
We need the period as an initial condition. |
| Methods inherited from class vec_math.AbstractFit |
|---|
formatError, formatValue, getChi2, getModelParameterErrors, getModelParameterValues, getR2, getRms, init, qualityOfFit, setConstant |
| Methods inherited from class util.PropertyBundles |
|---|
clone, getLocalized, getLocalized, getLocalizedString, getLocalizedString, loadResource |
| Methods inherited from class util.PropertyResources |
|---|
createFrom, createFrom, createFrom, getApplet, getAsResources, getLocalClassLoader, getPropertiesToKey, getPropertiesToKey, getResource, getResourceAsStream, getResourceFromKey, getResources, keyCreate, keyCreate, reload, setApplet |
| Methods inherited from class util.PropertyContainer |
|---|
augment, augment, augment, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, isNew, parseObject, reload, removeProperty, rescanned, setObject, setProperties, setProperty, stringProperties, toString |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface util.ResourceSupplying |
|---|
getResource, getResourceAsStream, getResources |
| Methods inherited from interface util.PropertySupplying |
|---|
defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsObject, getAsObject, getProperties, getProperty, has, parseObject, removeProperty, setObject, setProperty, stringProperties |
| Field Detail |
|---|
public static final String PERIOD
public static final String AMPLITUDE
public static final String OFFSET
public static final String T0
public static final String KEY_UNITAMPLITUDE
public static final String KEY_UNITPHASE
public static final String KEY_UNITPERIOD
public static final String KEY_UNITOFFSET
public static final String KEY_PERIOD
public static final String KEY_TINDEX
public static final String KEY_YINDEX
public static final String KEY_ITER
public static final String KEY_TERMINATE
public static final String KEY_EPSILON
public static final String KEY_LAMBDA
public static final String KEY_EXTERNALERROR
private static final int DEFTINDEX
private static final int DEFYINDEX
private static final String DEFUNITPERIOD
private static final String DEFUNITAMPLITUDE
private static final String DEFUNITPHASE
private static final String DEFUNITOFFSET
private List<Variable> fitted
private HarmonicFit.HarmonicModel phasemodel
| Constructor Detail |
|---|
public HarmonicFit(Map<String,String> prop)
| Method Detail |
|---|
public boolean setInitialCondition(Variable p)
setInitialCondition in interface ModelFittingsetInitialCondition in class AbstractFitpublic DataModel prepareFit(VectorG[] in)
GeneralRegression#harmonic. The three linear parameters are fit
into three fitting parameters OFFSET, AMPLITUDE,
and #PHASE, where phase and amplitude are calculated from the
linear parameters as
amplitude²=a_0²+b_0²
tan(ωt_0)=b_0/a_0;
The order of the returned array is at index zero amplitude, sigma
amplitude, at index one, offset plus sigma, and at index two phase plus
sigma.
in - An array of measurements. Each vector contains dependant
and independant variables and eventually their errors.
public List<Variable> fit()
PhaseFit. This fit has
the advantage that by transforming the amplitude, phase function into
a sin and cosine wave, we get a pure linear regression. This is done
here, the result is transformed back to match the original (non-linear)
model (holds also for parameter errors).
public DataModel getDataModel()
public List<Variable> getFittedParameters()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||