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

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.Linear
All Implemented Interfaces:
Evaluator<Double,Double>, PolynomialFunction.ClosedForm, DifferentiableEvaluator<Double,Double,Double>, DifferentiableUnivariateScalarFunction, ScalarFunction<Double>, UnivariateScalarFunction, CloneableSerializable, Serializable, Cloneable
Direct Known Subclasses:
AdaptiveRejectionSampling.LineSegment, PolynomialFunction.Quadratic
Enclosing class:
PolynomialFunction

public static class PolynomialFunction.Linear
extends AbstractDifferentiableUnivariateScalarFunction
implements PolynomialFunction.ClosedForm

Utilities for algebraic treatment of a linear polynomial of the form y(x) = q0 + q1*x

See Also:
Serialized Form

Field Summary
static double COLLINEAR_TOLERANCE
          Tolerance below which to consider something zero, 0.0
 
Constructor Summary
PolynomialFunction.Linear(double q0, double q1)
          Creates a new instance of Linear
 
Method Summary
 PolynomialFunction.Linear clone()
          This makes public the clone method on the Object class and removes the exception that it throws.
 double differentiate(double input)
          Differentiates the output of the function about the given input
 double evaluate(double input)
          Produces a double output for the given double input
static PolynomialFunction.Linear fit(InputOutputPair<Double,Double> p0, InputOutputPair<Double,Double> p1)
          Fits a linear (straight-line) curve to the given data points
static PolynomialFunction.Linear fit(InputOutputSlopeTriplet p0)
          Fits a linear (stright-line) curve to the given data point
 double getQ0()
          Getter for q0
 double getQ1()
          Getter for q1
 Double[] roots()
          Finds the real-valued roots (zero crossings) of the polynomial
 void setQ0(double q0)
          Setter for q0
 void setQ1(double q1)
          Setter for q1
 Double[] stationaryPoints()
          Finds the real-valued stationary points (zero slope) maxima or minima of the polynomial
 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.math.ScalarFunction
evaluateAsDouble
 
Methods inherited from interface gov.sandia.cognition.evaluator.Evaluator
evaluate
 
Methods inherited from interface gov.sandia.cognition.math.DifferentiableEvaluator
differentiate
 

Field Detail

COLLINEAR_TOLERANCE

public static final double COLLINEAR_TOLERANCE
Tolerance below which to consider something zero, 0.0

See Also:
Constant Field Values
Constructor Detail

PolynomialFunction.Linear

public PolynomialFunction.Linear(double q0,
                                 double q1)
Creates a new instance of Linear

Parameters:
q0 - Constant (zeroth-order) coefficient
q1 - Linear (first-order) coefficient
Method Detail

clone

public PolynomialFunction.Linear 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 CloneableSerializable
Overrides:
clone in class AbstractCloneableSerializable
Returns:
A clone of this object.

evaluate

public double evaluate(double input)
Description copied from interface: UnivariateScalarFunction
Produces a double output for the given double input

Specified by:
evaluate in interface UnivariateScalarFunction
Parameters:
input - Input to the Evaluator
Returns:
output at the given input

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

roots

public Double[] roots()
Description copied from interface: PolynomialFunction.ClosedForm
Finds the real-valued roots (zero crossings) of the polynomial

Specified by:
roots in interface PolynomialFunction.ClosedForm
Returns:
Array of roots, will never be null

stationaryPoints

public Double[] stationaryPoints()
Description copied from interface: PolynomialFunction.ClosedForm
Finds the real-valued stationary points (zero slope) maxima or minima of the polynomial

Specified by:
stationaryPoints in interface PolynomialFunction.ClosedForm
Returns:
Array of stationary points, will never be null

fit

public static PolynomialFunction.Linear fit(InputOutputPair<Double,Double> p0,
                                            InputOutputPair<Double,Double> p1)
Fits a linear (straight-line) curve to the given data points

Parameters:
p0 - First point
p1 - Second point
Returns:
closed-form Linear function representing the data points

fit

public static PolynomialFunction.Linear fit(InputOutputSlopeTriplet p0)
Fits a linear (stright-line) curve to the given data point

Parameters:
p0 - First point
Returns:
closed-form Linear function representing the data points

getQ0

public double getQ0()
Getter for q0

Returns:
Zeroth order coefficient

setQ0

public void setQ0(double q0)
Setter for q0

Parameters:
q0 - Zeroth order coefficient

getQ1

public double getQ1()
Getter for q1

Returns:
First-order coefficient

setQ1

public void setQ1(double q1)
Setter for q1

Parameters:
q1 - First-order coefficient

toString

public String toString()
Overrides:
toString in class Object