vec_math
Class AbstractFit

java.lang.Object
  extended by util.PropertyContainer
      extended by vec_math.AbstractFit
All Implemented Interfaces:
Cloneable, Initializable, PropertyBearing, ModelFitting
Direct Known Subclasses:
ExpressionFit, HarmonicFit, OrbitFit, PhaseRegression

public abstract class AbstractFit
extends PropertyContainer
implements ModelFitting

Base class for model fitters. Additionally provides parameter names and formatters for the parameters and their errors.


Nested Class Summary
 
Nested classes/interfaces inherited from class util.PropertyContainer
PropertyContainer.URLResource
 
Field Summary
private static Format DEFDEFAULTFORMAT
          A default decimal formatter for the error.
private  Map<String,DecimalFormat> errformat
          A lookup table for error formats.
static String KEY_DEFAULTERROR
          The default error format.
static String KEY_DEFAULTFORMAT
          The default value format.
static String KEY_ERRORFORMAT
          These are the error formatter strings.
static String KEY_PARAMETERFORMAT
          These are the parameters formatter strings.
private  Map<String,DecimalFormat> valformat
          A lookup table for value formats.
 
Fields inherited from class util.PropertyContainer
KEY_LISTSEPARATOR, KEY_LOCALECOUNTRY, KEY_LOCALELANGUAGE, KEY_MAPKEYVALUECHAR, KEY_MAPSEPARATOR, KEY_NOINITONCREATE, KEY_RESOURCEBUNDLES
 
Fields inherited from interface util.PropertyBearing
CONFIG, KEY_CLASS, KEY_URLRESOURCES, KEY_URLUSECONFIG, KEY_URLUSECURRENT, KEY_URLUSEHOME
 
Constructor Summary
protected AbstractFit(Map<String,String> prop)
          Constructs a new regression analyser.
 
Method Summary
 String formatError(Variable p)
          Formats the parameter errors using internal formats or generic, if not explicately given.
 String formatValue(Variable p)
          Formats the parameter values using internal formats or generic, if not explicately given.
 double getChi2()
          Returns the weighted chi-square sum.
static VectorG getModelParameterErrors(List<Variable> p)
          Converts a list of model parameters into an nvector of its values.
static VectorG getModelParameterValues(List<Variable> p)
          Converts a list of model parameters into an nvector of its values.
 double getR2()
          Returns the coefficient of determination, R², which is in a linear model the square of the correlation coefficient.
 double getRms()
          Returns the rms of the fitted model to the model data.
 void init()
          On init, we initialize our format maps, if available.
 double qualityOfFit()
          The quality of the fit, assuming normally distributed errors can be determined from the chi2 and the degree of freedoms.
 boolean setConstant(Variable c)
          Return false.
 boolean setInitialCondition(Variable c)
          Return false.
 
Methods inherited from class util.PropertyContainer
augment, augment, augment, clone, createFrom, createFrom, createFrom, defaultBoolean, defaultChar, defaultDouble, defaultFloat, defaultInt, defaultLong, defaultObject, defaultObject, defaultProperties, defaultProperty, getAsBoolean, getAsChar, getAsDouble, getAsEnums, getAsFloat, getAsInt, getAsList, getAsLong, getAsMap, getAsMap, getAsObject, getAsObject, getLocalClassLoader, getLocalized, getLocalized, getLocalizedString, getLocalizedString, getProperties, getPropertiesToKey, getPropertiesToKey, getProperty, getResource, getResourceAsStream, getResourceFromKey, getResources, has, isNew, keyCreate, keyCreate, parseObject, reload, 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 vec_math.ModelFitting
fit, getDataModel, getFittedParameters, prepareFit
 

Field Detail

KEY_PARAMETERFORMAT

public static final String KEY_PARAMETERFORMAT
These are the parameters formatter strings.

See Also:
Constant Field Values

KEY_ERRORFORMAT

public static final String KEY_ERRORFORMAT
These are the error formatter strings.

See Also:
Constant Field Values

KEY_DEFAULTFORMAT

public static final String KEY_DEFAULTFORMAT
The default value format.

See Also:
Constant Field Values

KEY_DEFAULTERROR

public static final String KEY_DEFAULTERROR
The default error format.

See Also:
Constant Field Values

DEFDEFAULTFORMAT

private static final Format DEFDEFAULTFORMAT
A default decimal formatter for the error.


valformat

private Map<String,DecimalFormat> valformat
A lookup table for value formats.


errformat

private Map<String,DecimalFormat> errformat
A lookup table for error formats.

Constructor Detail

AbstractFit

protected AbstractFit(Map<String,String> prop)
Constructs a new regression analyser.

Method Detail

init

public void init()
On init, we initialize our format maps, if available.

Specified by:
init in interface Initializable
Overrides:
init in class PropertyContainer

setConstant

public boolean setConstant(Variable c)
Return false. Subclasses that need constant from outside should override this.

Specified by:
setConstant in interface ModelFitting
Returns:
false, if the constant does not apply to this model.

setInitialCondition

public boolean setInitialCondition(Variable c)
Return false. Subclasses that need initial conditions from outside should override this.

Specified by:
setInitialCondition in interface ModelFitting
Returns:
false, if the initial condition does not apply to this model.

getRms

public double getRms()
Returns the rms of the fitted model to the model data.

Specified by:
getRms in interface ModelFitting

getChi2

public double getChi2()
Returns the weighted chi-square sum.

Specified by:
getChi2 in interface ModelFitting

getR2

public double getR2()
Returns the coefficient of determination, R², which is in a linear model the square of the correlation coefficient. The most general definition of the coefficient of determination is R^2 \equiv 1 - {SS_{\rm err}\over SS_{\rm tot}}.\,

Specified by:
getR2 in interface ModelFitting

qualityOfFit

public double qualityOfFit()
The quality of the fit, assuming normally distributed errors can be determined from the chi2 and the degree of freedoms.

Specified by:
qualityOfFit in interface ModelFitting

formatValue

public String formatValue(Variable p)
Formats the parameter values using internal formats or generic, if not explicately given.


formatError

public String formatError(Variable p)
Formats the parameter errors using internal formats or generic, if not explicately given.


getModelParameterValues

public static final VectorG getModelParameterValues(List<Variable> p)
Converts a list of model parameters into an nvector of its values.


getModelParameterErrors

public static final VectorG getModelParameterErrors(List<Variable> p)
Converts a list of model parameters into an nvector of its values.