com.perisic.function
Class LinCombOfFunctions
java.lang.Object
com.perisic.function.AnyFunction
com.perisic.function.LinCombOfFunctions
- Direct Known Subclasses:
- FourFunctions
public class LinCombOfFunctions
- extends AnyFunction
f(x) = w1 * f1(x) + ... + wn * fn(x)
n is the number of weights (length of the weight vector)
If the number of weights is less than the number of functions,
they will be considered as 0. If there are more weights than functions
the exceeding weights will be ignored.
Copyright:(c) Marc Conrad, Tim French 2010; Usage of the works is
permitted provided that this instrument is retained with the works,
so that any entity that uses the works is notified of this instrument.
DISCLAIMER: THE WORKS ARE WITHOUT WARRANTY.
- Author:
- Marc Conrad
Method Summary |
double |
eval(double x)
Evaluates the weighted combination of the functions at x. |
void |
setWeights(double[] theWeightsIn)
Sets the weights explicitly. |
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LinCombOfFunctions
public LinCombOfFunctions(AnyFunction[] inputFunctions,
double[] initialWeights)
- Parameters:
inputFunctions
- the functions {f1, ..., fn}initialWeights
- the weights for the functions, can be set to null (which returns const zero when evaluated)
setWeights
public void setWeights(double[] theWeightsIn)
- Sets the weights explicitly.
- Parameters:
theWeightsIn
- the weights.
eval
public double eval(double x)
- Evaluates the weighted combination of the functions at x. The
- Specified by:
eval
in class AnyFunction
- Parameters:
x
- The value against which the function is evaluated.
- Returns:
- f(x) where f is this object.