multivariable curve fitting with constraints

2 次查看(过去 30 天)
Hello,
I'm confused from all the least squares functions which is supported by Matlab: I have a function which is the basis for curve fitting f(x,y,z), some test input data:
xdata=[x,y,z];
and corresponding output data
ydata=y;
I'd like to perform curve fitting of f(x,y,z) to the test.
Some constraints that I would like to use:
x_a < x < x_b
y_a < y < y_b
z_a < z < z_b
f(x,y,z)>=0 for each x,y,z in the domain
Please assist with function which I should use and the corresponding input parameters for it.
Other option: based on the xdata, ydata and constraints, I'd like to get an analytic function f(x,y,z) which best fits the data and constraints.

回答(1 个)

Matt J
Matt J 2016-10-23
编辑:Matt J 2016-10-23
LSQCURVEFIT would be one choice,
x = lsqcurvefit(func,x0,xdata,ydata,lb,ub)
As you can see in the documentation, it readily allows you to specify upper and lower bounds lb and ub on the parameters, x. You have to decide on the parametric model and supply a function handle (func) to it of the form F(x,xdata). You would also have to provide an initial parameter guess x0 for the iterative estimation.
The positivity requirement on the function f(x,y,z)>0 will probably require you to choose a parametric family which is inherently positive, e.g., a Gaussian lobe mixture.
  4 个评论
michael
michael 2016-10-24
x0 is the initial assumption on unknown values of the function. In case of f(x)=ax+b, the unknowns are a,b and the bounds are on the value of x, not on the xdata!
Matt J
Matt J 2016-10-26
编辑:Matt J 2016-10-26
The bounds that you gave in your posted example are on f(x), namely f(x)>=0. x is an independent variable controlled by you.
Constraining f(x)>=0 over a continuous region of x is not something MATLAB has tools for for multi-dimensional x. For scalar x, you could use fsemininf().
The simplest way to ensure f(x)>=0 is to choose an f(x) that can never be negative for any choice of the unknowns. As I mentioned, an inherently positive parametric family like a mixture of Gaussians would do this.
If you're saying that you're stuck with a more complicated family, then the best solution will likely be specific to that family. For a linear family f(x)=ax+b, you would take advantage that f reaches its extremes at the vertices of the region lb < x < ub. Constraining a*x+b>=0 is then just a simple matter of imposing the linear constraints,
a*lb + b >=0
a*ub + b >=0
You could do the same thing for linear functions in n-dimensions.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by