File Exchange

image thumbnail

gapolyfitn

version 1.12.0.0 (37.5 KB) by Richard Crozier
optimises the functional form of a multi-dimensional polynomial fit to model data

2 Downloads

Updated 17 Dec 2013

View Version History

View License

This function implements a method of using genetic algorithms to optimise the form of a polynomial, i.e. reducing the number of terms required in comparison to a least-squares fit using all possible terms, as described in the following paper:

Clegg, J. et al, "The use of a genetic algorithm to optimize the functional form of a multi-dimensional polynomial fit to experimental data", 2005 IEEE Congress on Evolutionary Computation, 928-934, Edinburgh, September, 2005

A general polynomial of n variables can be represented as follows:

a1 * x1^2 * x2^4 * x3^1 * xn^p + a2 * x_1^6 * x2^3 * x3^1 * xn^p + ...

A linear least-square fit can find the values of the coefficients, represented as 'a' above, such that the error between the function and a set of data is minimized. If the functional form of the data is not known in advance this can require that all possible combinations of terms and powers up to a given size are used. As the number of terms in a polynomial is given by (n+(m-1))! / (n!)(m-1)! where n is the maximum power used and m is the number of variables, the number of all possible terms can become very large for multivariable models. For example, a model with 12 variables of up to order 8 would require 75582 terms. Furthermore this can require the inversion of an extremely large matrix in order to evaluate the regression model.

This function generates a population of polynomial forms which are each a subset of the set of all possible terms and evaluates them for their fit to the model data as given by the R-squared value returned by the function polyfitn. The population is then evolved using a genetic algorithm based on their relative scores. Evolution is achieved by mating successful individuals and the introduction of random mutations.

The function makes use of the free GA toolbox from the University of Sheffield Evolutionary Computing Team in the uk available here:

http://www.shef.ac.uk/acse/research/ecrg/gat.html

but the crucial subfunctions objpolyfit, crtpolyp, recpoly and mutpoly could no doubt easily be used with the MATLAB Genetic Algorithm and Direct search toolbox.

This function can use the multicore package provided on the file exchange but it is not required, simply always use the options.MCORE = false option (the default in any case).

Required/Reccomended functions can be currently found here:

GA toolbox (required):
http://codem.group.shef.ac.uk/index.php/ga-toolbox

polyfitn (required):
http://www.mathworks.co.uk/matlabcentral/fileexchange/34765-polyfitn

gfit2 (required):
http://www.mathworks.co.uk/matlabcentral/fileexchange/22020

randMat (required):
http://www.mathworks.co.uk/matlabcentral/fileexchange/24712

muticore (optional):
http://www.mathworks.co.uk/matlabcentral/fileexchange/13775

***** CAVEAT *****

gapolyfitn will happily fit very high order polynomials to your data. Be warned that such high order polynomials can give a good score, but suffer from high degrees of 'ringing' between the data points. Therefore users should take care when fitting their data using this tool.

Cite As

Richard Crozier (2020). gapolyfitn (https://www.mathworks.com/matlabcentral/fileexchange/25499-gapolyfitn), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (7)

Paul Stansell

@ENES GUL see required functions section above

ENES GUL

There is a problem, Undefined function or variable 'ranking'.

Richard Crozier

To anyone wondering where 'ranking' is, please read the description carefully, which explains where all dependencies can be found.

Jahetbe

I need "ranking" file.
How can I find it?

Richard Crozier

@Andrew Newell, I'm not sure why polyfitn has been removed. I will see if the author is happy for me to provide a copy of polyfitn with gapolyfitn.

Andrew Newell

Polyfitn has been removed from the FEX. Do you have any idea why?

Martin Kaszynski

Great tool - thanks!

MATLAB Release Compatibility
Created with R2008a
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!