[scilab-Users] Weighting data in datafit
Samuel Gougeon
sgougeon at free.fr
Thu Jan 5 23:44:41 CET 2012
Hi,
The W parameter of datafit() is not for weighting data but for weighting
fitting
criteria. Indeed, datafit can be used with several distances to be
minimized,
and the final criterium used is a weighted average of them. For instance,
you can define the minimal vertical average distance between points and
the model,
or the horizontal distance, etc, and then state that the vertical
average distance
must count for 2/3, and the horizontal one for 1/3, etc.
datafit() is unable to weight data. I have modified it ~one year ago to
do so.
I am attaching a modified release.
After compiling datafit.sci with Scinotes, just type
head_comments datafit
to get help about the syntax with weighted data : The weighting matrix
can be inserted just after the matrix of points.
Several examples with weighted data are provided in the help.
Using weighted data is much more standard than supporting weighted fitting
multi-criteria. It is somewhat puzzling that implemented priorities have
been
inverted.
HTH
Samuel
Le 05/01/2012 05:49, zugvogel a écrit :
> Hello,
> I'm having a lot of trouble figuring out how to weight data-points for
> fitting using "datafit".
>
> I have:
> [p,err]=datafit(G,ndata,W,p0)
>
> The function G is:
> function e=G(p, z), // output is "e", input "p" and "z"
> y=z(1),x=z(2); // y is the top row, x bottom
> e=y-FF(x,p), // optimise to zero, FF is my function
> endfunction
>
> ndata is 2 rows and 12 columns, the top row being y-axis values and the
> bottom row being x-axis values
>
> p0 is 4 rows and 1 column.
>
> W is my weighting matrix. I set this initially as just a 12x12 identity
> matrix.
>
> I just can't get this to work however. I keep getting:
>
> -------------------
> -->[p,err]=datafit(G,ndata,W,p0)
> !--error 15
> Submatrix incorrectly defined.
>
> at line 26 of function costf called by :
> at line 174 of function datafit called by :
> [p,err]=datafit(G,ndata,W,p0)
> -------------------
>
> Can anyone help me? I have tried changing W in many ways but I can't get it
> to work.
> The help section on datafit says W should be of size ne x ne, where G is
> size ne x 1. I assume ne is the same as nz (ie, 12, the number of data
> points) but maybe this is wrong? In any case I tried make ne=1,2,3...12
> (always a square matrix) but without success. If I do it without weighting,
> it works.
>
> I would really appreciate any help. I'm completely out of ideas.
>
> Thank you!
>
> Tom
>
> --
> View this message in context: http://mailinglists.scilab.org/Weighting-data-in-datafit-tp3633921p3633921.html
> Sent from the Scilab users - Mailing Lists Archives mailing list archive at Nabble.com.
>
> --
> To unsubscribe from this mailing-list, please send an empty mail to
> users-unsubscribe at lists.scilab.org
> To check the archives of this mailing list, see
> http://mailinglists.scilab.org/
>
>
>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: datafit.sci
URL: <https://lists.scilab.org/pipermail/users/attachments/20120105/410c2f9d/attachment.ksh>
More information about the users
mailing list