As a relative beginner in Python, i'm struggling to understand (and therefore use) the "curve_fit" from scipy.optimize
I've tried following answers to previous questions: python numpy/scipy curve fitting and exponential curve fitting with python but unfortunately had no luck getting it to work.
This is an engineering problem (dealing with measured data from a test rig), therefore I know that the formula is in the format Y=(X/A)+(X/B)^(1/C) where A,B,C are the constants that need to be found
[Current Code]
import numpy as np
from scipy.optimize import curve_fit
valY_list = [yyy1,yyy2,yyy3,yyy4]
valX_list = [xxx1,xxx2,xxx3,xxx4]
val_Y = np.array(valY_list)
val_X = np.array(valX_list)
def fit_func(val_X,A,B,C):
return (val_X/A)+((val_X/B)^(1/C))
params = curve_fit(fit_func, val_X, val_Y)
[A,B,C] = params[0]
NB1: in reality valY_list & valX_list are >500 entries long (stored as floats).
NB2: I also know that the values of A, B, C should be within a certain range of values, so I want to constrain the solution when it performs the optimisation.
0.005 < A < 0.5
0.0 < B < 5000
0.0001 < C < 0.1
I realise that my code is probably quite rudimentary, and likely has lots of things missing (or glaringly obvious mistakes for an experienced coder!) so my apologies. Any help would be appreciated!