Re: fit by varying the data

"Patrick Dupre" <[email protected]>
Newsgroups gmane.comp.graphics.gnuplot.user
Message-ID <trinity-96842188-3db0-4c3e-9476-f84025eaca5c-1560897366660@3c-app-mailcom-bs04>
Hello Hans,

It seems difficult to speak with you.
I do not have a 3D cloud of points, just 2 sets of points (same length) with the
same x, and I need to fit a linear combination of these y1 and y2 with a
parameter (here theta) to fit the combination with a know (and simple) function
(which has 2 parameters to adjust).
Indeed, I can currently solve my problem visually by using gnuplot.
I "just need" to minimize the sum  of the square between a given function
and a set of data (which depend on 1 parameter).
Whatever are these data, they just have to be recalculated for each new fitted parameters
(actually for only one parameter).
Any minimization algorithm does that, except that in general, is does not have to recalculate
the dataset, but basically it is the same procedure.
I did it a thousand of times, but not with gnuplot, and I wanted to do
the same with gnuplot.

Please note that doing
(x=$1):
works perfectly well.
There is maybe other option, but I can also want to do (x=$1/1000):

When I said:

y(x) = $2 (x) *sin(theta) + $3 (x) *cos(theta)

it should have maybe said:
y(i) = $2 (i) *sin(theta) + $3 (i) *cos(theta)
where i is the index of the array, and assuming that $2 is a dataset
that I index with i.
Actually, I do not know how to said that with the words of gnuplot, but
if you tell me how to calculate
the minimum of (y(x) - f(x))^2 for 3 parameters, I shall be happy.
(x can be an index).

My Best.

===========================================================================
 Patrick DUPRÉ                                 | | email: [email protected]
 Laboratoire interdisciplinaire Carnot de Bourgogne
 9 Avenue Alain Savary, BP 47870, 21078 DIJON Cedex FRANCE
 Tel: +33 (0)380395988
===========================================================================


> Sent: Wednesday, June 19, 2019 at 12:01 AM
> From: "Hans-Bernhard Bröker" <[email protected]>
> To: gnuplot <[email protected]>
> Subject: Re: [Gnuplot-info] fit by varying the data
>
> Am 18.06.2019 um 21:33 schrieb Patrick Dupre:
> > Sorry,
> > 
> > Why it does not make sense?
> 
> Because it doesn't.  Assigning data to 'x' makes no sense because that's
> what giving those data as the first "using" specifier already does, and
> because 'x is not available to be assigned.
> 
> > I need to fit 3 parameters,
> > x0, a and theta
> > by minimizing the sum of the square root:
> > The function depend only on x (and of the parameters, x0 and a)
> > while I have 2 sets of that $2 and $3 (which depend on the same 
> > x).
> > I only know a linear combination of this 2 sets that can be fitted
> > y(x) = $2 (x) *sin(theta) + $3 (x) *cos(theta)
> 
> No, you don't know that combination.  Which is why you're looking for it.
> 
> > There is no fundamental glitch.
> 
> I'm not convinced you've quite reached the point where you should be the
> sole judge on that.
> 
> > The 2 set of data are issue from the same experiment.
> > Typically, it is vector whose you want to fit the direction.
> 
> As given, no, it's not.  You have a cloud of points in 3D.  What you're
> trying to fit is, for all practical intents and purposes, a plane
> through that cloud.  Except that, for some reason, you want to express
> the orientation of that plane partially as an angle, partially as a slope.
> 
> And the easiest way of doing that may well be to turn things around:
> express $1 as a function of $2 and $3, and fit that.
> 
> fit (cos(theta)*x+sin(theta)*y)/a + x0 'data' using 2:3:1 via a, x0, theta
> 
> 
> > I need to re-read the datasets which are stored in $DATA
> 
> No, you don't.  You need to re-format your problem statement to
> eliminate that apparent need.
> 
> 
> _______________________________________________
> gnuplot-info mailing list
> [email protected]
> Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info
>


_______________________________________________
gnuplot-info mailing list
[email protected]
Membership management via: https://lists.sourceforge.net/lists/listinfo/gnuplot-info
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.