Parameter Estimation Toolkit

The toolkit contains Matlab code that I've written to test various parameter estimation schemes. It really is code cut out of the directories that I'm working in, so you can't really take anything for granted. It also uses function handles and things like that which can make it a little difficult to read some of the files. The advantage of this, however is that it is easy to add new estimation methods, and problems, to the system. The original version of this stuff came from Darren Gawley.

The code itself (version 2) is here, but I'll try to give you a bit of an idea how it works so you can see what's going on.

The main files that run the various tests are in the Scripts directory, and an ordinary example would be AntsFNSTestScript.m. What it does is generate some data with noise, run the estimators over the data, collect the results, and saves the results. The important parts of this process are thus

  1. The data generation code. You need to add code to generate data for every new problem you want to use the package on. I've included the code to generate image points over a sequence, but this bit really needs work at the moment. It's a bit more complicated than it needs to be and the code to calculate the area which is visible to both cameras has a couple of holes in it. It still works reasonably thought and I am working on improving it.
  2. The estimators. Each estimator is a function which takes a carrier, some data and possibly a factor matrix and a few other parameters and computes an estimate. The idea is to make this as problem independent as possible. The problem dependent information is all stored in the carriers. Some estimation processes can actually be used on multiple estimation techniques. The main example of this is repeatedly finding the eigenvector corresponding to the smallest eigen value. In order not to have the same code duplicated we thus have Factor Matrices too. There are a number of estimators which don't use factor matrices of course.
    • Factor matrices. The matrix X in FNS is a factor matrix, but then so is Z in CFNS and the algebraic least squares matrix M = sum(u_i^T * u_i). A factor matrix file thus takes the data and an estimate of the parameters and constructs a matrix which we repeatedly find the null space of in FNS.m
    • Carriers are the means by which estimators and factor matrices access the data. The carrier for the fundamental matrix estimation problem for instance packs a pair of corresponding points x into a 9 element carrier vector u(x). All of the estimators access the data through the carriers. This means that regardless of the problem you can write an estimator that asks for u, or its derivative, or whatever. Unfortunately this means that a carrier actually winds up being just a function that determines what other functions need to be called on the basis of the input. This isn't the fastest way to do things, but it is very flexible and really helps you re-use your code.
  3. Error measures. An error measure can take a number of parameters, one of which might be a carrier. The error measure that calculates the approximated maximum likelihood error for instance takes a carrier so it can generate u(x) and its derivative.

The estimators and such are also written so as to be as modular as possible, so if you want to calculate the algebraic least squares estimate you would write

als(@FMatCarrier,imagePoints,@alsFactorMatrix)

but to do Hartley style normalisation on the data first, and correct the estimate afterwards you'd just wrap in in the normaliser

normEst({@als,@FMatCarrier,ND,@alsFactorMatrix},imagePoints,@HartleyNormaliseFData)

The @ symbols indicate that what you're actually passing as a parameter is a pointer to the named function, so what this second line actually means is that there's an estimator called normEst which takes a cell array of parameters, some image points, and a normalisation routine. What it does is Normalise the data, then apply the method who's function handle is the first element of the cell array. The parameters that are passed to the method are those indicated by the rest of the cell array, except the the normalised data is passed in place of the 'ND' flag. The estimate, once calculated, is then adjusted to undo the normalisation transformation, and passed back. This means that you can run any estimator you want on normalised data just by wrapping it in normEst. The advantages of this as a way of organising the code are huge.

The file AntsFNSTestScript.m actually stores these commands in an array, and prints out a results file which includes the names. This means that later you can go back to the results file and see pretty much exactly what each of the methods is.

The best way to get things going is to run the script AntsFNSTestScript.m. You may get error messages depending on whether you've got the optimisation toolkit and that sort of thing, but it should work for you.

Let me know if it doesn't.

I'm releasing this code for research purposes. If you use the code I would appreciate it if you let me know how it works for you and if you cite the fact that you've used it in any papers that arise. This code is not intended to be used for commercial purposes of any sort without my express permission. (Sorry about that, but you know how these things go).