Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.graphics.apps.gnuplot > #2758 > unrolled thread

fit two variables to a complex function

Started bylamr64@gmail.com
First post2015-02-18 16:36 -0800
Last post2015-02-25 23:59 +0100
Articles 6 — 3 participants

Back to article view | Back to comp.graphics.apps.gnuplot


Contents

  fit two variables to a complex function lamr64@gmail.com - 2015-02-18 16:36 -0800
    Re: fit two variables to a complex function Karl <mail.kfr@gmx.net> - 2015-02-19 16:24 +0100
      Re: fit two variables to a complex function Karl <mail.kfr@gmx.net> - 2015-02-19 16:36 +0100
      Re: fit two variables to a complex function Karl <mail.kfr@gmx.net> - 2015-02-19 17:30 +0100
        Re: fit two variables to a complex function luis <lamr64@gmail.com> - 2015-02-19 15:38 -0800
        Re: fit two variables to a complex function Karl <mail.kfr@gmx.net> - 2015-02-25 23:59 +0100

#2758 — fit two variables to a complex function

Fromlamr64@gmail.com
Date2015-02-18 16:36 -0800
Subjectfit two variables to a complex function
Message-ID<ab8d731f-9d22-4a55-8ecd-12d540e2de8e@googlegroups.com>
Hi,
I'm trying to fit a two parameter complex f(freq,temp) function to a dataset. Since I know that I can't really use complex-valued functions I'm following the advice I found on line: I split my data file so that I have the first dataset on the file be the real part and the second the imaginary part. My problem is that all the examples on the web use the second argument on the function to switch between the real and the imaginary functions to fit, so I'm not sure if it is even possible. I tried to use the column function like so:

f2(x,t) = ((column(-2)%2)==0) ? Re_f(x,t) : Im_f(x,t)

but I get, not completely unexpectedly:

fit f2(x,y) DATAFILE every ::9 using 1:2:9:11 via A0
column() called from invalid context

if, stretching some of the examples, I try:

f2(x,t,z) = (z==0) ? f(x,t) : phi(x,t)
fit f2(x,y,z) DATAFILE every ::9 using 1:2:-1:9:11 via A0

I get:

undefined variable: z

Any ideas?

Thanks

[toc] | [next] | [standalone]


#2761

FromKarl <mail.kfr@gmx.net>
Date2015-02-19 16:24 +0100
Message-ID<mc4v7n$5m2$1@news.rz.uni-karlsruhe.de>
In reply to#2758
Am 19.02.2015 um 01:36 schrieb lamr64@gmail.com:
> Hi,
> I'm trying to fit a two parameter complex f(freq,temp) function to a dataset. Since I know that I can't really use complex-valued functions I'm following the advice I found on line: I split my data file so that I have the first dataset on the file be the real part and the second the imaginary part. My problem is that all the examples on the web use the second argument on the function to switch between the real and the imaginary functions to fit, so I'm not sure if it is even possible. I tried to use the column function like so:
> 
> f2(x,t) = ((column(-2)%2)==0) ? Re_f(x,t) : Im_f(x,t)
> 
> but I get, not completely unexpectedly:
> 
> fit f2(x,y) DATAFILE every ::9 using 1:2:9:11 via A0
> column() called from invalid context
> 
> if, stretching some of the examples, I try:
> 
> f2(x,t,z) = (z==0) ? f(x,t) : phi(x,t)
> fit f2(x,y,z) DATAFILE every ::9 using 1:2:-1:9:11 via A0
> 
> I get:
> 
> undefined variable: z
> 
> Any ideas?
> 
> Thanks

Can´t you just make the temperature your switch, by feeding a negative T
value for the imaginary dataset?

f2(x,t) = ((column(-2)%2)==0) ? Re_f(x,t) : Im_f(x,-t)

fit f2(x,y) DATAFILE every ::9 \
   using 1:((column(-2)%2) == 0 ? $1 : -$1):9:11 via A0

(not tested ;-))

  Karl


[toc] | [prev] | [next] | [standalone]


#2762

FromKarl <mail.kfr@gmx.net>
Date2015-02-19 16:36 +0100
Message-ID<mc4vt6$66v$1@news.rz.uni-karlsruhe.de>
In reply to#2761
Am 19.02.2015 um 16:24 schrieb Karl:

>    using 1:((column(-2)%2) == 0 ? $1 : -$1):9:11 via A0

Should read

    using 1:((column(-2)%2) == 0 ? $2 : -$2):9:11 via A0

of course.

[toc] | [prev] | [next] | [standalone]


#2763

FromKarl <mail.kfr@gmx.net>
Date2015-02-19 17:30 +0100
Message-ID<mc532c$959$1@news.rz.uni-karlsruhe.de>
In reply to#2761
Am 19.02.2015 um 16:24 schrieb Karl:
> Am 19.02.2015 um 01:36 schrieb lamr64@gmail.com:
>> Hi,
>> I'm trying to fit a two parameter complex f(freq,temp) function to a dataset. Since I know that I can't really use complex-valued functions I'm following the advice I found on line: I split my data file so that I have the first dataset on the file be the real part and the second the imaginary part. My problem is that all the examples on the web use the second argument on the function to switch between the real and the imaginary functions to fit, so I'm not sure if it is even possible. I tried to use the column function like so:
>>
>> f2(x,t) = ((column(-2)%2)==0) ? Re_f(x,t) : Im_f(x,t)
>>
>> but I get, not completely unexpectedly:
>>
>> fit f2(x,y) DATAFILE every ::9 using 1:2:9:11 via A0
>> column() called from invalid context
>>
>> if, stretching some of the examples, I try:
>>
>> f2(x,t,z) = (z==0) ? f(x,t) : phi(x,t)
>> fit f2(x,y,z) DATAFILE every ::9 using 1:2:-1:9:11 via A0
>>
>> I get:
>>
>> undefined variable: z
>>
>> Any ideas?
>>
>> Thanks
> 
> Can´t you just make the temperature your switch, by feeding a negative T
> value for the imaginary dataset?
> 
> f2(x,t) = ((column(-2)%2)==0) ? Re_f(x,t) : Im_f(x,-t)
> 
> fit f2(x,y) DATAFILE every ::9 \
>    using 1:((column(-2)%2) == 0 ? $1 : -$1):9:11 via A0
> 

This of course couldn't work, because column() can only be used in the
using statement. That one here does the trick, however:

f(x,y) = (y>0) ? Re_f(x,y) : Im_f(x,-y)

fit f(x,y) "data" \
	us 1:2:(column(-2)%2==0?$3:-$3) via a

You could even use an imaginary independent variable to switch between
the two parts, i guess. In case you need negative temperatures ;-)

  K

[toc] | [prev] | [next] | [standalone]


#2768

Fromluis <lamr64@gmail.com>
Date2015-02-19 15:38 -0800
Message-ID<826ea7e1-cccb-4583-af15-4c4b758bcce7@googlegroups.com>
In reply to#2763
On Thursday, February 19, 2015 at 8:30:05 AM UTC-8, Karl wrote:
> Am 19.02.2015 um 16:24 schrieb Karl:
> > Am 19.02.2015 um 01:36 schrieb :
> >> Hi,
> >> I'm trying to fit a two parameter complex f(freq,temp) function to a dataset. Since I know that I can't really use complex-valued functions I'm following the advice I found on line: I split my data file so that I have the first dataset on the file be the real part and the second the imaginary part. My problem is that all the examples on the web use the second argument on the function to switch between the real and the imaginary functions to fit, so I'm not sure if it is even possible. I tried to use the column function like so:
> >>
> >> f2(x,t) = ((column(-2)%2)==0) ? Re_f(x,t) : Im_f(x,t)
> >>
> >> but I get, not completely unexpectedly:
> >>
> >> fit f2(x,y) DATAFILE every ::9 using 1:2:9:11 via A0
> >> column() called from invalid context
> >>
> >> if, stretching some of the examples, I try:
> >>
> >> f2(x,t,z) = (z==0) ? f(x,t) : phi(x,t)
> >> fit f2(x,y,z) DATAFILE every ::9 using 1:2:-1:9:11 via A0
> >>
> >> I get:
> >>
> >> undefined variable: z
> >>
> >> Any ideas?
> >>
> >> Thanks
> > 
> > Can´t you just make the temperature your switch, by feeding a negative T
> > value for the imaginary dataset?
> > 
> > f2(x,t) = ((column(-2)%2)==0) ? Re_f(x,t) : Im_f(x,-t)
> > 
> > fit f2(x,y) DATAFILE every ::9 \
> >    using 1:((column(-2)%2) == 0 ? $1 : -$1):9:11 via A0
> > 
> 
> This of course couldn't work, because column() can only be used in the
> using statement. That one here does the trick, however:
> 
> f(x,y) = (y>0) ? Re_f(x,y) : Im_f(x,-y)
> 
> fit f(x,y) "data" \
> 	us 1:2:(column(-2)%2==0?$3:-$3) via a
> 
> You could even use an imaginary independent variable to switch between
> the two parts, i guess. In case you need negative temperatures ;-)
> 
>   K

Yes, I like that. I think that should work ... Thanks!

[toc] | [prev] | [next] | [standalone]


#2791

FromKarl <mail.kfr@gmx.net>
Date2015-02-25 23:59 +0100
Message-ID<mclk3v$7qk$1@news.rz.uni-karlsruhe.de>
In reply to#2763
Am 19.02.2015 um 17:30 schrieb Karl:
> Am 19.02.2015 um 16:24 schrieb Karl:
>> Am 19.02.2015 um 01:36 schrieb lamr64@gmail.com:
>>> Hi,
>>> I'm trying to fit a two parameter complex f(freq,temp) function to a dataset. Since I know that I can't really use complex-valued functions I'm following the advice I found on line: I split my data file so that I have the first dataset on the file be the real part and the second the imaginary part. My problem is that all the examples on the web use the second argument on the function to switch between the real and the imaginary functions to fit, so I'm not sure if it is even possible. I tried to use the column function like so:
>>>
>>> f2(x,t) = ((column(-2)%2)==0) ? Re_f(x,t) : Im_f(x,t)
>>>
>>> but I get, not completely unexpectedly:
>>>
>>> fit f2(x,y) DATAFILE every ::9 using 1:2:9:11 via A0
>>> column() called from invalid context
>>>
>>> if, stretching some of the examples, I try:
>>>
>>> f2(x,t,z) = (z==0) ? f(x,t) : phi(x,t)
>>> fit f2(x,y,z) DATAFILE every ::9 using 1:2:-1:9:11 via A0
>>>
>>> I get:
>>>
>>> undefined variable: z
>>>
>>> Any ideas?
>>>
>>> Thanks
>>
>> Can´t you just make the temperature your switch, by feeding a negative T
>> value for the imaginary dataset?
>>
>> f2(x,t) = ((column(-2)%2)==0) ? Re_f(x,t) : Im_f(x,-t)
>>
>> fit f2(x,y) DATAFILE every ::9 \
>>    using 1:((column(-2)%2) == 0 ? $1 : -$1):9:11 via A0
>>
> 
> This of course couldn't work, because column() can only be used in the
> using statement. That one here does the trick, however:
> 
> f(x,y) = (y>0) ? Re_f(x,y) : Im_f(x,-y)
> 
> fit f(x,y) "data" \
> 	us 1:2:(column(-2)%2==0?$3:-$3) via a
> 
> You could even use an imaginary independent variable to switch between
> the two parts, i guess. In case you need negative temperatures ;-)


alternative:

 fit abs(f(x3,x4)-(x1+i*x2)) dataf using 1:2:3:4:(0):(1) via ....

It sort of fitting the other way round: All data points are zero, and
the function contains the residuals, that are minimised.

I´m mostly convinced this works as I expect it. ;-)

  K

[toc] | [prev] | [standalone]


Back to top | Article view | comp.graphics.apps.gnuplot


csiph-web