ca.nengo.math.impl
Class WeightedCostApproximator

java.lang.Object
  extended by ca.nengo.math.impl.WeightedCostApproximator
All Implemented Interfaces:
LinearApproximator, java.io.Serializable, java.lang.Cloneable

public class WeightedCostApproximator
extends java.lang.Object
implements LinearApproximator

A LinearApproximator in which error is evaluated at a fixed set of points, and the cost function that is minimized is a weighted integral of squared error.

Uses the Moore-Penrose pseudoinverse.

TODO: test

Author:
Bryan Tripp
See Also:
Serialized Form

Nested Class Summary
static class WeightedCostApproximator.Factory
          An ApproximatorFactory that produces WeightedCostApproximators.
 
Constructor Summary
WeightedCostApproximator(float[][] evaluationPoints, float[][] values, Function costFunction, float noise, int nSV)
           
WeightedCostApproximator(float[][] evaluationPoints, float[][] values, Function costFunction, float noise, int nSV, boolean quiet)
           
 
Method Summary
 LinearApproximator clone()
           
 float[] findCoefficients(Function target)
          This implementation is adapted from Eliasmith & Anderson, 2003, appendix A.
 float[][] getEvalPoints()
           
 float[][] getValues()
           
 double[][] pseudoInverse(double[][] matrix, float minSV, int nSV)
          Override this method to use a different pseudoinverse implementation (eg clustered).
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WeightedCostApproximator

public WeightedCostApproximator(float[][] evaluationPoints,
                                float[][] values,
                                Function costFunction,
                                float noise,
                                int nSV,
                                boolean quiet)
Parameters:
evaluationPoints - Points at which error is evaluated (should be uniformly distributed, as the sum of error at these points is treated as an integral over the domain of interest). Examples include vector inputs to an ensemble, or different points in time within different simulation regimes.
values - The values of whatever functions are being combined, at the evaluationPoints. Commonly neuron firing rates. The first dimension makes up the list of functions, and the second the values of these functions at each evaluation point.
costFunction - A cost function that weights squared error over the domain of evaluation points
noise - Standard deviation of Gaussian noise to add to values (to reduce sensitivity to simulation noise) as a proportion of the maximum absolute value over all values

WeightedCostApproximator

public WeightedCostApproximator(float[][] evaluationPoints,
                                float[][] values,
                                Function costFunction,
                                float noise,
                                int nSV)
Method Detail

getEvalPoints

public float[][] getEvalPoints()
Specified by:
getEvalPoints in interface LinearApproximator
Returns:
Points at which target functions are evaluated. Each row (or float[]) corresponds to a single evaluation point. These points should usually be uniformly distributed, because the sum of error at these points is treated as an integral over the domain of interest.
See Also:
LinearApproximator.getEvalPoints()

getValues

public float[][] getValues()
Specified by:
getValues in interface LinearApproximator
Returns:
The values of component functions at the evaluation points. The first dimension makes up the list of functions, and the second the values of these functions at each evaluation point.
See Also:
LinearApproximator.getValues()

pseudoInverse

public double[][] pseudoInverse(double[][] matrix,
                                float minSV,
                                int nSV)
Override this method to use a different pseudoinverse implementation (eg clustered).

Parameters:
matrix - Any matrix
minSV - Hint as to smallest singular value to use
nSV - Max number of singular values to use
Returns:
The pseudoinverse of the given matrix

findCoefficients

public float[] findCoefficients(Function target)

This implementation is adapted from Eliasmith & Anderson, 2003, appendix A.

It solves PHI = GAMMA" UPSILON, where " denotes pseudoinverse, UPSILON_i = < cost(x) x a_i(x) >, and GAMMA_ij = < cost(x) a_i(x) a_j(x) >. <> denotes integration (the sum over eval points).

Specified by:
findCoefficients in interface LinearApproximator
Parameters:
target - Function to approximate
Returns:
coefficients on component functions which result in an approximation of the target
See Also:
LinearApproximator.findCoefficients(ca.nengo.math.Function)

clone

public LinearApproximator clone()
                         throws java.lang.CloneNotSupportedException
Specified by:
clone in interface LinearApproximator
Overrides:
clone in class java.lang.Object
Throws:
java.lang.CloneNotSupportedException