Class ContinuousVariable

java.lang.Object
edu.cmu.tetrad.data.AbstractVariable
edu.cmu.tetrad.data.ContinuousVariable
All Implemented Interfaces:
Variable, Node, TetradSerializable, Serializable, Comparable<Node>

public final class ContinuousVariable extends AbstractVariable implements Variable
Represents a real-valued variable. The values are doubles, and the default missing value marker for is Double.NaN.
Version:
$Id: $Id
Author:
Willie Wheeler 07/99, josephramsey modifications 12/00
See Also:
  • Constructor Details

    • ContinuousVariable

      public ContinuousVariable(String name)
      Constructs a new continuous variable with the given name.
      Parameters:
      name - the name of the variable.
    • ContinuousVariable

      public ContinuousVariable(ContinuousVariable variable)
      Copy constructor.
      Parameters:
      variable - a ContinuousVariable object
  • Method Details

    • serializableInstance

      public static ContinuousVariable serializableInstance()
      Generates a simple exemplar of this class to test serialization.
      Returns:
      a ContinuousVariable object
    • getDoubleMissingValue

      public static double getDoubleMissingValue()

      getDoubleMissingValue.

      Returns:
      the missing value marker.
    • isDoubleMissingValue

      public static boolean isDoubleMissingValue(double value)
      Determines whether the argument is equal to the missing value marker.
      Parameters:
      value - the Object to test--should be a wrapped version of the missing value marker.
      Returns:
      true iff it really is a wrapped version of the missing value marker.
    • checkValue

      public boolean checkValue(Object value)
      Checks to see whether the passed value can be converted into a value for this variable.

      Checks to see whether the passed value is an acceptable value for this variable. For AbstractVariable, this method always returns true. Subclasses should override checkValue() in order to provide for subclass-specific value checking. The value should pass the test if it can be converted into an equivalent object of the correct class type (see getValueClass()) for this variable; otherwise, it should fail. In general, checkValue() should not fail a value for simply not being an instance of a particular class. Since this method is not static, subclasses may (but need not) provide for instance-specific value checking.

      Checks the value to make sure it's a legitimate value for this column.

      Specified by:
      checkValue in interface Variable
      Overrides:
      checkValue in class AbstractVariable
      Parameters:
      value - The object value to be checked. For instance, for a continuous variable, this would be a Double, for a discrete variable, and Integer, etc.
      Returns:
      true iff the object is a valid value for this variable.
    • like

      public Node like(String name)
      Creates a new node of the same type as this one with the given name.
      Specified by:
      like in interface Node
      Specified by:
      like in class AbstractVariable
      Parameters:
      name - the name of the new node.
      Returns:
      the new node.
    • getMissingValueMarker

      public Object getMissingValueMarker()

      getMissingValueMarker.

      Specified by:
      getMissingValueMarker in interface Variable
      Specified by:
      getMissingValueMarker in class AbstractVariable
      Returns:
      the missing value marker, wrapped as a Double.
    • isMissingValue

      public boolean isMissingValue(Object value)
      Tests whether the given value is the missing data marker.

      Tests whether the given value is the missing data marker.

      Determines whether the argument is equal to the missing value marker.

      Specified by:
      isMissingValue in interface Variable
      Specified by:
      isMissingValue in class AbstractVariable
      Parameters:
      value - The object value one wants to check as a missing value.
      Returns:
      true iff the given object is equals to getMissingValueMarker().
    • hashCode

      public int hashCode()

      hashCode.

      Specified by:
      hashCode in interface Node
      Overrides:
      hashCode in class Object
      Returns:
      a int
    • equals

      public boolean equals(Object o)
      Tests whether this variable is equal to the given variable.

      Two continuous variables are equal if they have the same name and the same missing value marker.

      Specified by:
      equals in interface Node
      Overrides:
      equals in class Object
      Parameters:
      o - a Object object
      Returns:
      true iff this variable is equal to the given variable.
    • getNodeType

      public NodeType getNodeType()

      Getter for the field nodeType.

      Specified by:
      getNodeType in interface Node
      Returns:
      a NodeType object
    • setNodeType

      public void setNodeType(NodeType nodeType)
      Sets the node type for this node.
      Specified by:
      setNodeType in interface Node
      Parameters:
      nodeType - the node type for this node.
    • getCenterX

      public int getCenterX()

      Getter for the field centerX.

      Specified by:
      getCenterX in interface Node
      Returns:
      the x coordinate of the center of the node.
    • setCenterX

      public void setCenterX(int centerX)
      Sets the x coordinate of the center of this node.

      Sets the x coordinate of the center of this node.

      Specified by:
      setCenterX in interface Node
      Parameters:
      centerX - This coordinate.
    • getCenterY

      public int getCenterY()

      Getter for the field centerY.

      Specified by:
      getCenterY in interface Node
      Returns:
      the y coordinate of the center of the node.
    • setCenterY

      public void setCenterY(int centerY)
      Sets the y coordinate of the center of this node.

      Sets the y coordinate of the center of this node.

      Specified by:
      setCenterY in interface Node
      Parameters:
      centerY - This coordinate.
    • setCenter

      public void setCenter(int centerX, int centerY)
      Sets the (x, y) coordinates of the center of this node.

      Sets the (x, y) coordinates of the center of this node.

      Specified by:
      setCenter in interface Node
      Parameters:
      centerX - The x coordinate.
      centerY - The y coordinate.
    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener l)
      Adds a property change listener.

      Adds a property change listener.

      Specified by:
      addPropertyChangeListener in interface Node
      Parameters:
      l - This listener.
    • getNodeVariableType

      public NodeVariableType getNodeVariableType()
      Returns the node shape for this node.
      Specified by:
      getNodeVariableType in interface Node
      Returns:
      the intervention type
    • setNodeVariableType

      public void setNodeVariableType(NodeVariableType nodeVariableType)
      Sets the type (domain, interventional status, interventional value..) for this node variable
      Specified by:
      setNodeVariableType in interface Node
      Parameters:
      nodeVariableType - the type (domain, interventional status, interventional value..) for this node variable
    • getAllAttributes

      public Map<String,Object> getAllAttributes()

      getAllAttributes.

      Specified by:
      getAllAttributes in interface Node
      Returns:
      a Map object
    • getAttribute

      public Object getAttribute(String key)

      getAttribute.

      Specified by:
      getAttribute in interface Node
      Parameters:
      key - a String object
      Returns:
      a Object object
    • removeAttribute

      public void removeAttribute(String key)

      removeAttribute.

      Specified by:
      removeAttribute in interface Node
      Parameters:
      key - a String object
    • addAttribute

      public void addAttribute(String key, Object value)

      addAttribute.

      Specified by:
      addAttribute in interface Node
      Parameters:
      key - a String object
      value - a Object object