gov.sandia.cognition.learning.function.scalar
Class ThresholdFunction

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.math.AbstractScalarFunction<Double>
          extended by gov.sandia.cognition.math.AbstractUnivariateScalarFunction
              extended by gov.sandia.cognition.learning.function.scalar.ThresholdFunction
All Implemented Interfaces:
Evaluator<Double,Double>, Vectorizable, ScalarFunction<Double>, UnivariateScalarFunction, CloneableSerializable, Serializable, Cloneable

public class ThresholdFunction
extends AbstractUnivariateScalarFunction
implements Vectorizable

Maps the input space onto the set {LOW_VALUE,HIGH_VALUE}. Values below the threshold are assigned to LOW_VALUE, Values above (or equal to) the threshold are assigned to HIGH_VALUE

Since:
1.0
Author:
Kevin R. Dixon
See Also:
Serialized Form

Field Summary
static double DEFAULT_HIGH_VALUE
          Default high value, 1.0
static double DEFAULT_LOW_VALUE
          Default low value, -1.0
static double DEFAULT_THRESHOLD
          Default threshold, 0.0
 
Constructor Summary
ThresholdFunction()
          Default constructor
ThresholdFunction(double threshold)
          Creates a new instance of ThresholdFunction
ThresholdFunction(double threshold, double lowValue, double highValue)
          Creates a new instance of ThresholdFunction
 
Method Summary
 ThresholdFunction clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 void convertFromVector(Vector parameters)
          Converts this function from its parameters, which consists of the threshold value
 Vector convertToVector()
          Converts this function into its parameters, which consists of the threshold value
 double evaluate(double input)
          Maps the input onto the set {LOW_VALUE, HIGH_VALUE}
 double getHighValue()
          Getter for highValue
 double getLowValue()
          Getter for lowValue
 double getThreshold()
          Getter for threshold
 void setHighValue(double highValue)
          Setter for highValue
 void setLowValue(double lowValue)
          Setter for lowValue
 void setThreshold(double threshold)
          Setter for threshold
 
Methods inherited from class gov.sandia.cognition.math.AbstractUnivariateScalarFunction
evaluate, evaluateAsDouble
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_THRESHOLD

public static final double DEFAULT_THRESHOLD
Default threshold, 0.0

See Also:
Constant Field Values

DEFAULT_LOW_VALUE

public static final double DEFAULT_LOW_VALUE
Default low value, -1.0

See Also:
Constant Field Values

DEFAULT_HIGH_VALUE

public static final double DEFAULT_HIGH_VALUE
Default high value, 1.0

See Also:
Constant Field Values
Constructor Detail

ThresholdFunction

public ThresholdFunction()
Default constructor


ThresholdFunction

public ThresholdFunction(double threshold)
Creates a new instance of ThresholdFunction

Parameters:
threshold - Current threshold, below which a value is assigned lowValue, above which (or equal to) is assigned highValue

ThresholdFunction

public ThresholdFunction(double threshold,
                         double lowValue,
                         double highValue)
Creates a new instance of ThresholdFunction

Parameters:
threshold - Current threshold, below which a value is assigned lowValue, above which (or equal to) is assigned highValue
lowValue - Values below threshold are assigned this value
highValue - Values above (or equal to) threshold are assigned this value
Method Detail

clone

public ThresholdFunction clone()
Description copied from class: AbstractCloneableSerializable
This makes public the clone method on the Object class and removes the exception that it throws. Its default behavior is to automatically create a clone of the exact type of object that the clone is called on and to copy all primitives but to keep all references, which means it is a shallow copy. Extensions of this class may want to override this method (but call super.clone() to implement a "smart copy". That is, to target the most common use case for creating a copy of the object. Because of the default behavior being a shallow copy, extending classes only need to handle fields that need to have a deeper copy (or those that need to be reset). Some of the methods in ObjectUtil may be helpful in implementing a custom clone method. Note: The contract of this method is that you must use super.clone() as the basis for your implementation.

Specified by:
clone in interface Vectorizable
Specified by:
clone in interface CloneableSerializable
Overrides:
clone in class AbstractCloneableSerializable
Returns:
A clone of this object.

evaluate

public double evaluate(double input)
Maps the input onto the set {LOW_VALUE, HIGH_VALUE}

Specified by:
evaluate in interface UnivariateScalarFunction
Parameters:
input - Input to consider
Returns:
(input >= threshold) ? HIGH_VALUE : LOW_VALUE

convertToVector

public Vector convertToVector()
Converts this function into its parameters, which consists of the threshold value

Specified by:
convertToVector in interface Vectorizable
Returns:
one-element Vector consisting of the threshold value

convertFromVector

public void convertFromVector(Vector parameters)
Converts this function from its parameters, which consists of the threshold value

Specified by:
convertFromVector in interface Vectorizable
Parameters:
parameters - one-element Vector specifying the threshold value

getThreshold

public double getThreshold()
Getter for threshold

Returns:
Current threshold, below which a value is assigned LOW_VALUE, above which (or equal to) is assigned HIGH_VALUE

setThreshold

public void setThreshold(double threshold)
Setter for threshold

Parameters:
threshold - Current threshold, below which a value is assigned LOW_VALUE, above which (or equal to) is assigned HIGH_VALUE

getHighValue

public double getHighValue()
Getter for highValue

Returns:
Values above (or equal to) threshold are assigned this value

setHighValue

public void setHighValue(double highValue)
Setter for highValue

Parameters:
highValue - Values above (or equal to) threshold are assigned this value

getLowValue

public double getLowValue()
Getter for lowValue

Returns:
Values below threshold are assigned this value

setLowValue

public void setLowValue(double lowValue)
Setter for lowValue

Parameters:
lowValue - Values below threshold are assigned this value