Polynomial line fitting

Here follows simple polynomial (of order 0, 1 or 2) line-fitting is considered. Example m-files can be found in the SIPPI/examples/case_linefit folder.

First, the forward problem is defined. Then examples of stochastic inversion using SIPPI is demonstrated using a a synthetic data set.

The forward problem

The forward problem consists of computing the y-value as a function of the x-position of the data, and the polynomial coefficients determining the line. sippi_forward_linefit.m:

% sippi_forward_linefit Line fit forward solver for SIPPI 
%
% [d,forward,prior,data]=sippi_forward_linefit(m,forward,prior,data);
%
function [d,forward,prior,data]=sippi_forward_linefit(m,forward,prior,data);

if length(m)==1;
    d{1}=forward.x*m{1};
elseif length(m)==2;
    d{1}=forward.x*m{1}+m{2};
else
    d{1}=forward.x.^2*m{1}+forward.x*m{2}+m{3};
end

the forward.x must be an array of the x-locations, for which the y-values of the corresponding line will be evaluated.

Note that the prior must be defined such that prior{1} refer to the intercept, prior{2} to the gradient, and prior{3} to the 2nd order polynomial coefficient.

If only one prior type is defined then the forward response will just be a constant, and if two prior types are defined, then the forward response will be a straight line.