[scilab-Users] Weighting data in datafit

Mathieu Dubois mathieu.dubois at limsi.fr
Thu Jan 5 12:02:43 CET 2012


As far as I understand the help page, ne is the dimension of the output 
of G(p, z) (which I think is the error function).
In the example provided on the help page ne=1 so you can modify it this way:
W=rand(1);
[p,err]=datafit(G,Z,p0,W);
This runs but I'm not sure to understand what is the purpose of this 
parameter (I can't relate it to [1]).

It is said that datafit minimize 
G(p,z_1)'WG(p,z_1)+G(p,z_2)'WG(p,z_2)+...+G(p,z_n)'WG(p,z_n) (where z_i 
is the
I would think that the weighting matrix should have one entry per data 
(so n*ne or ne*n)...

You could check the the leastsq function in which the weighting 
parameter makes more sense to me (the weights are arguments of the cost).

Mathieu

[1] http://en.wikipedia.org/wiki/Least_squares#Weighted_least_squares

On 01/05/2012 05:49 AM, zugvogel wrote:
> 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/
>




More information about the users mailing list