|
From: James R. V. Z. <jr...@co...> - 2009-02-06 03:09:20
|
Ethan Merritt <merritt@u.washington.edu> writes:
> On Saturday 31 January 2009 17:37:51 James R. Van Zandt wrote:
> >
> > Currently gnuplot has these data formats for fitting functions with
> > one or two independent variables:
> >
> > y
> > x:y
> > x:y:s
> > x:y:z:s
> >
> > I propose to implement these additional data formats for fitting
> > functions with 3-5 independent variables:
> >
> > v:x:y:z:s
> > u:v:x:y:z:s
> > t:u:v:x:y:z:s
> I am not familiar with the "fit" subsystem, so I may be missing
> some essential point....
> but the above looks very strange to me. Why stick your additional
> dummy variables at the start rather than the end? Surely it is
> more natural to have
> x
> x:y
> x:y:z
x:y:z:t
x:y:z:t:u
> x:y:z:t:u:v
Currently, the number of using specs determines the number of
independent variables. If there are two independent variables, there
must be four using specs - one for each of those independent
variables, one for the dependent variable, and one for the error.
> > Linear regression would look like this:
> >
> > h(v,x,y) = a*v + b*x + c*y
> > fit h(v,x,y) 'foo.dat' using 1:2:3:4:(1) via a,b,c
>
> Wouldn't it be far more natural to say
> h(x,y,z) = a*x + b*y + c*z
> fit h(x,y,z) 'foo.dat' using 1:2:3:4 via a,b,c
There are several issues here:
First, you have four specs, which would mean there are two independent
variables. I would rather not not add some other mechanism to specify
the number of independent variables, so for three independent variables
we need to add a spec for the error. E.g.:
fit <expression> 'foo.dat' using 1:2:3:4:(1) via a,b,c
Next we need to decide what to call the colums. At present, we are
using Z for the dependent variable, S for the error, and X and Y for
independent variables. It turns out that each column of data read
from a file must be associated with an axis (that's how the minimum
and maximum values are stored). So for the rest of the independent
variables I chose the axes with names nearest X.
Third, we need to decide order of the columns read from the data file.
I am assuming the independent variables are first, then the dependent
variable, then the error.
Fourth, how to allocate dummy variable names to the columns. I chose
alphabetical order. We could instead say that the first two dummy
variables are always X and Y, and we add others in reverse
alphabetical order:
x:z
x:z:s
x:y:z:s
x:y:v:z:s
x:y:v:u:z:s
x:y:v:u:t:z:s
Or we could start with T and add in alphabetical order:
x:z:s
x:y:z:s
x:y:t:z:s
x:y:t:u:z:s
x:y:t:u:v:z:s
I think these would be more awkward.
On the other hand, we could require the user to supply a range spec
with a dummy variable name for each independent variable. That way he
could use whatever names he likes. The only rules would be that the
first range spec corresponds to the first using spec, etc., and the
last two using specs would still be for the dependent variable and the
error. E.g.:
fit [lat=*:*] [lon=0:pi] [alt=0:4000] a*sin(lat)+b*cos(lon)+c*alt \
'foo.dat' using 1:2:3:4:(1) via a,b,c
The data file might start like this:
# lat lon alt temp
2.34 48.86 211 13
5.37 43.31 820 22
4.83 45.76 443 8
1.45 43.62 411 23
7.27 43.70 331 32
-1.57 47.23 282 18
I think I would still need to store the min and max values in
axis_array entries. I could add some extra entries, so I don't
interfere with the current axes.
BTW I'm still debugging. So far the new code only works with one
independent variable...
- Jim Van Zandt
|