1

I am trying to perform global fitting with two parameters sharing. Now I got a message 'AttributeError: 'float' object has no attribute 'exp'.

The code is as follows:


    import numpy as np
    import symfit as sf
    import matplotlib.pyplot as plt

    x=     #data from dataframe
    y1=    #data from dataframe
    y2=    #data from dataframe   
    y3=    #data from dataframe


    x_1, x_2, x_3, y_1, y_2, y_3 = sf.variables('x_1, x_2, x_3, y_1, y_2, y_3')
    A0_0, A1_0, A0_1, A1_1, A2_1, A0_2, A1_2, tau1, tau2 = sf.parameters('A0_0, A1_0, A0_1, A1_1, A2_1, A0_2, A1_2, tau1, tau2')

    globalmodel = sf.Model({
        y_1: A0_0 + A1_0 * sf.exp(-x_1 / tau1),
        y_2: A0_1 + A1_1 * sf.exp(-x_2 / tau1) + A1_1 * sf.exp(-x_2 / tau2),
        y_3: A0_2 + A1_2 * sf.exp(-x_3 / tau2),
    })


    globalfit = sf.Fit(globalmodel, x_1=t, x_2=t, x_3=t, y_1=y1, y_2=y2, y_3=y3)
    globalfit_result = globalfit.execute()
    print(globalfit_result)

    y_r = globalmodel(x_1=t, x_2=t, x_3=t, **globalfit_result.params)

I used this online resource as reference. I don't what is wrong with my code. This might be a basic problem. It will be of great help to point the mistake in my code.

kei
  • 11
  • 2
  • Hi @kei, which version of numpy, symfit etc. are you using? If I recall correctly this happens with a certain version of numpy. So maybe you can check if it matches the requirements https://github.com/tBuLi/symfit/blob/master/requirements.txt – tBuLi Mar 12 '20 at 14:24

0 Answers0