5

I want to fit multiple bounded functions in gnuplot, fitting the bound values as well.

For example:

f(x)=a          (for x < b)

f(x)=a+(x-b)**c (for x > b)

fit f(x) 'data.dat' via a,b,c

Is there a way to do this?

mgilson
  • 300,191
  • 65
  • 633
  • 696

1 Answers1

3

Hmmm... interesting. Why don't you try the following:

f(x)=(x<b)?a:a+(x-b)**c
fit f(x) 'data.dat' via a,b,c

tested by @george (see comments). Thanks george!

mgilson
  • 300,191
  • 65
  • 633
  • 696
  • just had to try that - yes it works.. I expected some horrible fit but it actually did good for some data I made up.. – agentp Sep 20 '12 at 18:49
  • @george -- I'm glad it works. I've been meaning to put together a little test, I just hadn't gotten around to it. – mgilson Sep 20 '12 at 18:52