net.sourceforge.openforecast
Class Observation
- java.lang.Object
-
- net.sourceforge.openforecast.Observation
-
- All Implemented Interfaces:
- DataPoint
public class Observation extends java.lang.Object implements DataPoint
Represents a single observation or data point, consisting of one value of a dependent variable, and one or more values of independent variables. Note that an Observation can refer to a previously observed data value, or a future forecast value (an expected Observation).- Since:
- 0.3
-
-
Constructor Summary
Constructors Constructor and Description Observation(DataPoint dataPoint)Like a copy constructor, but constructs a new Observation object by making a copy of the values from the given data point.Observation(double dependentValue)Initializes the current Observation with the given value of the dependent variable.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description booleanequals(DataPoint dp)Compares the given DataPoint to the current DataPoint/Observation, and returns true if, and only if, the two data points represent the same data point.doublegetDependentValue()Returns the current value assigned to the dependent variable.doublegetIndependentValue(java.lang.String name)Returns the current value assigned to the named independent variable.java.lang.String[]getIndependentVariableNames()Returns an array of all independent variable names.voidsetDependentValue(double value)Sets the dependent variables' value to the given value.voidsetIndependentValue(java.lang.String name, double value)Sets the named independent variables' value to the given value.java.lang.StringtoString()Overrides the default toString method to provide a more meaningful output of an Observation.
-
-
-
Constructor Detail
-
Observation
public Observation(double dependentValue)
Initializes the current Observation with the given value of the dependent variable. Note that this is provided as somewhat of a convenience - it will be necessary to call setIndependentValue for each independent variable name and value associated with this data point- Parameters:
dependentValue- the initial value of the dependent variable.
-
Observation
public Observation(DataPoint dataPoint)
Like a copy constructor, but constructs a new Observation object by making a copy of the values from the given data point.- Parameters:
dataPoint- the data point that is to be copied.
-
-
Method Detail
-
setDependentValue
public void setDependentValue(double value)
Sets the dependent variables' value to the given value.- Specified by:
setDependentValuein interfaceDataPoint- Parameters:
value- the new value for the dependent variable.
-
getDependentValue
public double getDependentValue()
Returns the current value assigned to the dependent variable. This value can be changed by calling setDependentValue.- Specified by:
getDependentValuein interfaceDataPoint- Returns:
- the current value of the dependent variable.
-
setIndependentValue
public void setIndependentValue(java.lang.String name, double value)Sets the named independent variables' value to the given value. Each Observation can have one or more name-value pairs that represent the independent variables and their associated values.- Specified by:
setIndependentValuein interfaceDataPoint- Parameters:
value- the new value for the dependent variable.
-
getIndependentValue
public double getIndependentValue(java.lang.String name)
Returns the current value assigned to the named independent variable. This value can be changed by calling setIndependentValue.- Specified by:
getIndependentValuein interfaceDataPoint- Parameters:
name- the name of the independent variable required.- Returns:
- the current value of the named independent variable.
-
getIndependentVariableNames
public java.lang.String[] getIndependentVariableNames()
Returns an array of all independent variable names. No checks are made to ensure that the names are unique. Rather, the names are extracted directly from the names used in defining and initializing the Observation.- Specified by:
getIndependentVariableNamesin interfaceDataPoint- Returns:
- an array of independent variable names for this Observation.
-
equals
public boolean equals(DataPoint dp)
Compares the given DataPoint to the current DataPoint/Observation, and returns true if, and only if, the two data points represent the same data point. That is, the dependent value matches and all the independent values match.
-
toString
public java.lang.String toString()
Overrides the default toString method to provide a more meaningful output of an Observation. Each independent variable is listed with its value, then the dependent variable and its value are listed.- Overrides:
toStringin classjava.lang.Object- Returns:
- a string representation of this Observation.
-
-
DataMelt 3.0 © DataMelt by jWork.ORG