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

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.math.AbstractDifferentiableUnivariateScalarFunction
                  extended by gov.sandia.cognition.learning.function.scalar.PolynomialFunction
All Implemented Interfaces:
Evaluator<Double,Double>, ParameterGradientEvaluator<Double,Vector>, DifferentiableEvaluator<Double,Double,Double>, DifferentiableUnivariateScalarFunction, Vectorizable, ScalarFunction<Double>, UnivariateScalarFunction, CloneableSerializable, Serializable, Cloneable

public class PolynomialFunction
extends AbstractDifferentiableUnivariateScalarFunction
implements ParameterGradientEvaluator<Double,Vector>

A single polynomial term specified by a real-valued exponent. Evaluates for "y" such that y=x^a, where "x" is the input and "a" is the real-valued exponent.

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

Nested Class Summary
static interface PolynomialFunction.ClosedForm
          Describes functionality of a closed-form algebraic polynomial function
static class PolynomialFunction.Cubic
          Algebraic treatment for a polynomial of the form y(x) = q0 + q1*x + q2*x^2 + q3*x^3
static class PolynomialFunction.Linear
          Utilities for algebraic treatment of a linear polynomial of the form y(x) = q0 + q1*x
static class PolynomialFunction.Quadratic
          Utilities for algebraic treatment of a quadratic polynomial of the form y(x) = q0 + q1*x + q2*x^2.
static class PolynomialFunction.Regression
          Performs Linear Regression using an arbitrary set of PolynomialFunction basis functions
 
Constructor Summary
PolynomialFunction(double exponent)
          Creates a new instance of PolynomialFunction
PolynomialFunction(PolynomialFunction other)
          Copy Constructor
 
Method Summary
 PolynomialFunction clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 Vector computeParameterGradient(Double input)
          Computes the derivative of the output with respect to the parameters for a particular input.
 void convertFromVector(Vector parameters)
          Sets the value of the exponent
 Vector convertToVector()
          Returns the value of the exponent
static ArrayList<PolynomialFunction> createPolynomials(double... polynomialExponents)
          Creates an array of PolynomialFunctions from the array of their exponents
 double differentiate(double input)
          Differentiates the output of the function about the given input
 double evaluate(double input)
          Evaluates the polynomial for the given input, returning Math.pow( input, exponent )
 double getExponent()
          Getter for exponent
 void setExponent(double exponent)
          Setter for exponent
 String toString()
           
 
Methods inherited from class gov.sandia.cognition.math.AbstractDifferentiableUnivariateScalarFunction
differentiate
 
Methods inherited from class gov.sandia.cognition.math.AbstractUnivariateScalarFunction
evaluate, evaluateAsDouble
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface gov.sandia.cognition.evaluator.Evaluator
evaluate
 
Methods inherited from interface gov.sandia.cognition.math.ScalarFunction
evaluateAsDouble
 

Constructor Detail

PolynomialFunction

public PolynomialFunction(double exponent)
Creates a new instance of PolynomialFunction

Parameters:
exponent - Real-valued exponent of this polynomial

PolynomialFunction

public PolynomialFunction(PolynomialFunction other)
Copy Constructor

Parameters:
other - PolynomialFunction to copy
Method Detail

clone

public PolynomialFunction 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.

convertToVector

public Vector convertToVector()
Returns the value of the exponent

Specified by:
convertToVector in interface Vectorizable
Returns:
Exponent of this polynomial

convertFromVector

public void convertFromVector(Vector parameters)
Sets the value of the exponent

Specified by:
convertFromVector in interface Vectorizable
Parameters:
parameters - Exponent of this polynomial

differentiate

public double differentiate(double input)
Description copied from interface: DifferentiableUnivariateScalarFunction
Differentiates the output of the function about the given input

Specified by:
differentiate in interface DifferentiableUnivariateScalarFunction
Parameters:
input - Input about which to compute the derivative of the function output
Returns:
Derivative of the output with respect to the input

evaluate

public double evaluate(double input)
Evaluates the polynomial for the given input, returning Math.pow( input, exponent )

Specified by:
evaluate in interface UnivariateScalarFunction
Parameters:
input - Input about which to compute the polynomial
Returns:
Math.pow(input,exponent)

computeParameterGradient

public Vector computeParameterGradient(Double input)
Description copied from interface: ParameterGradientEvaluator
Computes the derivative of the output with respect to the parameters for a particular input.

Specified by:
computeParameterGradient in interface ParameterGradientEvaluator<Double,Vector>
Parameters:
input - Input about which to compute the parameter gradient
Returns:
Change of the parameters with respect to the output

toString

public String toString()
Overrides:
toString in class Object

getExponent

public double getExponent()
Getter for exponent

Returns:
Real-valued exponent of this polynomial

setExponent

public void setExponent(double exponent)
Setter for exponent

Parameters:
exponent - Real-valued exponent of this polynomial

createPolynomials

public static ArrayList<PolynomialFunction> createPolynomials(double... polynomialExponents)
Creates an array of PolynomialFunctions from the array of their exponents

Parameters:
polynomialExponents - Exponents for the various polynomials
Returns:
Array of PolynomialFunctions from the given exponents