gov.sandia.cognition.learning.function.scalar
Class LinearCombinationScalarFunction<InputType>

java.lang.Object
  extended by gov.sandia.cognition.util.AbstractCloneableSerializable
      extended by gov.sandia.cognition.learning.function.LinearCombinationFunction<InputType,Double>
          extended by gov.sandia.cognition.learning.function.scalar.LinearCombinationScalarFunction<InputType>
Type Parameters:
InputType - Input class for the basis function
All Implemented Interfaces:
Evaluator<InputType,Double>, Regressor<InputType>, Vectorizable, ScalarFunction<InputType>, CloneableSerializable, Serializable, Cloneable

public class LinearCombinationScalarFunction<InputType>
extends LinearCombinationFunction<InputType,Double>
implements Regressor<InputType>

A weighted linear combination of scalar functions.

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

Constructor Summary
LinearCombinationScalarFunction(ArrayList<? extends Evaluator<InputType,Double>> basisFunctions, Vector coefficients)
          Creates a new instance of LinearCombinationFunction
LinearCombinationScalarFunction(Collection<? extends Evaluator<InputType,Double>> basisFunctions)
          Creates a new instance of LinearCombinationFunction
 
Method Summary
 LinearCombinationScalarFunction<InputType> clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 Double evaluate(InputType input)
          Evaluates the LinearCombinationFunction about the given input.
 double evaluateAsDouble(InputType input)
          Evaluates the scalar function as a double.
 
Methods inherited from class gov.sandia.cognition.learning.function.LinearCombinationFunction
convertFromVector, convertToVector, getBasisFunctions, getCoefficients, setBasisFunctions, setCoefficients, toString
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

LinearCombinationScalarFunction

public LinearCombinationScalarFunction(Collection<? extends Evaluator<InputType,Double>> basisFunctions)
Creates a new instance of LinearCombinationFunction

Parameters:
basisFunctions - Collection of basis functions to combine to produce the output

LinearCombinationScalarFunction

public LinearCombinationScalarFunction(ArrayList<? extends Evaluator<InputType,Double>> basisFunctions,
                                       Vector coefficients)
Creates a new instance of LinearCombinationFunction

Parameters:
basisFunctions - Collection of basis functions to combine to produce the output
coefficients - Coefficients for the basisFunctions
Method Detail

clone

public LinearCombinationScalarFunction<InputType> 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 LinearCombinationFunction<InputType,Double>
Returns:
A clone of this object.

evaluate

public Double evaluate(InputType input)
Description copied from class: LinearCombinationFunction
Evaluates the LinearCombinationFunction about the given input. The output is produced as: y = a0*f0(x) + a1*f1(x) + ... + an*fn(x), where "y" is the output, "x" is the given input, "ai" is the ith coefficient and "fi" is the ith basis function

Specified by:
evaluate in interface Evaluator<InputType,Double>
Specified by:
evaluate in class LinearCombinationFunction<InputType,Double>
Parameters:
input - The input about which to compute the output
Returns:
y = a0*f0(x) + a1*f1(x) + ... + an*fn(x)

evaluateAsDouble

public double evaluateAsDouble(InputType input)
Description copied from interface: ScalarFunction
Evaluates the scalar function as a double.

Specified by:
evaluateAsDouble in interface ScalarFunction<InputType>
Parameters:
input - The input value.
Returns:
The scalar output calculated from the given input.