help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fixed points piecewise-linear fitting


From: c.
Subject: Re: fixed points piecewise-linear fitting
Date: Sun, 18 Mar 2012 17:58:23 +0100

On 18 Mar 2012, at 16:21, Sergei Steshenko wrote:

> Could you please be more specific and tell us which functions to use/tweak ?
> 
> I had a very brief look at the project website, there is a lot of info and a
> lot of functions (IIRC in 3 packages) are available.
> 
> Thanks,
>   Sergei.

If I understood correctly what Juan Pablo suggested, he proposes to restate 
your problem as follows (I'll use W instead of Xf and Z instead of Yf for 
brevity)

Let Y(x) be the piece-wise linear function interpolating your data [X_i, Y_i], 
i=1...M
Let V be the P1 space of finite elements defined on the grid {W_j}, j=1...N < M 
and let {v_j (x)}, j=1...N  be the lagrangian basis of V
Let Z(x) = sum_{j=1}^N Z_j v_j(x)

You could restate your problem as:

find the set of coefficients Z_j that minimizes 

  J(Z) = \int_{W_1}^{W_N} (Z(x) - Y(x)) ^2 dx

notice that this is _NOT_ the same quantity you ask to minimize in your 
original post,
whether it is more or less appropriate than your choice depends on whether you 
need to minimize
the maximum error or some sort of "average" of it.

The adavantage of this formulation is that, unlike your case which requires 
solving a nonlinear system, 
it reduces to a linear system of equations of the form 

A * u = b

where 

u(j) = Z_j, 
A(i, j) = \int_{W_1}^{W_N} v_i(x) v_j(x),
b(i) = \int_{W_1}^{W_N} v_i(x) Y(x) 

this is essentially the same approach as used in geopdes to set boundary 
conditions, as explained in section 4.6 of the documentation.
The functions used for that are op_u_v and op_f_v from the package geopdes_base.

The tweaking required is mainly due to the fact that you cannot use gaussian 
quadrature as Y(x) is not smooth enough, so you need to define your own 
quadrature rule.


HTH,
Carlo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]