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

Fit data to data with gnuplot?



I was asked by a student if the following is doable with gnuplot:
 
Suppose you have a number of data sets (x_i,y_i)_j where i=1,...,n
represents the lines of each individual data set and j=1,...,N represents 
the index of the data sets.

For example (n=5, N=2):

1 2         1 2
2 2         2 2
3 3         3 4
4 6         4 8
5 0         5 2


You have also a binned data set (X_i,Y_i) where each Y_i is
supposed to be the weighted sum of the y_j above, i.e 
Y_i = w_1*y_{i,1} + w_2*y_{i,2} + ... + w_N*y_{i,N}, with unknown
weights w_j.

For example:

1 3
2 3
3 5
4 10
5 1

Now you want to do a least-square fit for the weights w_j to
minimize the square of the residuals (Y_i - (w_1*y_{i,1} +
w_2*y_{i,2} + ...)^2 (in the example above: w_1=1.0 and w_2=0.5).

I am tempted to say that this is not at all doable with gnuplot, 
unless someone here comes up with a fancy solution.

Best regards - Juergen

-- 
GPG A997BA7A | 87FC DA31 5F00 C885 0DC3  E28F BD0D 4B33 A997 BA7A



Reply to: