Bottom Page

• 0 Vote(s) - 0 Average
• 1
• 2
• 3
• 4
• 5
 how to get x values based on y-axis values from curvefit function python_newbie09 Not Blown Up Yet Posts: 53 Threads: 25 Joined: Jan 2018 Reputation: 4 Likes received: 0 #1 Sep-18-2019, 08:20 AM Hi, I have fitted a function for extrapolation and now I would like to get the x value when y is of a certain value. How do I get this? ```def func(x, b1, b2): return b1*np.exp(-b2*(x)) x = np.array([47,77,103,129,152,177,207,234,255,282,311,337,358,382,416,440,463,490,512,535,566,573]) y = np.array([0.904996,0.946489,0.931208,0.930137,0.915004,0.92138,0.911744,0.908241,0.894834,0.895659,0.897973,0.885373,0.895916,0.883586,0.880162,0.857255,0.872408,0.87055,0.855421,0.854406,0.852419,0.853073]) popt, pcov = curve_fit(func, x, y, p0=[0.1,0.1]) plt.plot(x, y, 'x') xx = np.linspace(0, 2000, 100) yy = func(xx, *popt) plt.plot(xx, yy, lw=1) ```Thanks. scidam Posts: 671 Threads: 1 Joined: Mar 2018 Reputation: 90 Likes received: 103 #2 Sep-19-2019, 02:09 AM This problem can be solved in many ways, e.g. consider the following: ```from scipy.optimize import root_scalar root_scalar(lambda x: func(x, *popt) - your_y_value, bracket=[0, 10000], method='bisect')``` « Next Oldest | Next Newest »

Top Page

 Possibly Related Threads... Thread Author Replies Views Last Post F-score and Recall values Greater Than 1 Hani 5 186 May-13-2020, 01:47 AM Last Post: Hani F-score, Precision, and Recall values Hani 3 288 May-09-2020, 08:16 AM Last Post: ThomasL Basic storage of function values for monte carlo simulation glidecode 1 222 Apr-15-2020, 01:41 AM Last Post: jefsummers How to copy a .csv worksheet into a .xlsx file without the number values turning into YoshikageKira 7 297 Mar-28-2020, 10:38 AM Last Post: buran Counter to keep track how many times values in a list appear in each row in a column chief 0 141 Mar-24-2020, 08:14 PM Last Post: chief How to obtain values under All when the margins of pivot_table is set to True? new_to_python 0 151 Mar-03-2020, 02:54 PM Last Post: new_to_python replace nan values by mean group by date.year, date.month wissam1974 5 1,893 Feb-19-2020, 06:25 PM Last Post: AnkitGupta Identifying consecutive masked values in a 3D data array chai0404 12 876 Feb-01-2020, 12:59 PM Last Post: perfringo Graph that shows predicted vs true values donnertrud 1 192 Jan-28-2020, 07:47 PM Last Post: jefsummers values spiral out of control Tinfoil 0 139 Jan-16-2020, 03:43 PM Last Post: Tinfoil

Forum Jump:

Users browsing this thread: 1 Guest(s)