tBuLi / symfit

Symbolic Fitting; fitting as it should be.
http://symfit.readthedocs.org
MIT License
233 stars 17 forks source link

Is it possible to fit a*x**b + c? #272

Closed lesshaste closed 4 years ago

lesshaste commented 4 years ago

I would like to perform a least-squares fit to a curve. I tried

a, b,c  = parameters('a, b, c')
x = variables('x')
model = a*x**b + c

However symfit complains about the exponentiation with

AttributeError: 'Tuple' object has no attribute '_eval_power'

Is this possible to do in symfit?

pckroon commented 4 years ago

Yes, but variables returns a tuple (of Variables). Two solutions:

a, b,c  = parameters('a, b, c')
x, = variables('x')  # Note the extra comma
model = a*x**b + c

or

x = Variable('x')
lesshaste commented 4 years ago

Thank you so much.